129 lines
3.5 KiB
C#
129 lines
3.5 KiB
C#
using AxibugEmuOnline.Client.ClientCore;
|
|
using AxibugEmuOnline.Client.Event;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AxibugEmuOnline.Client
|
|
{
|
|
public class InGameUI : CommandExecuter
|
|
{
|
|
public static InGameUI Instance { get; private set; }
|
|
|
|
public RomFile RomFile => m_rom;
|
|
public override bool Enable => gameObject.activeInHierarchy;
|
|
|
|
/// <summary> 寧刻맡踏狗茄절角뤠뇹黨젬샙친駕 </summary>
|
|
public bool IsNetPlay
|
|
{
|
|
get
|
|
{
|
|
if (!App.user.IsLoggedIn) return false;
|
|
if (App.roomMgr.mineRoomMiniInfo == null) return false;
|
|
if (App.roomMgr.RoomState <= AxibugProtobuf.RoomGameState.OnlyHost) return false;
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private RomFile m_rom;
|
|
public IEmuCore Core { get; private set; }
|
|
private object m_state;
|
|
|
|
private List<OptionMenu> menus = new List<OptionMenu>();
|
|
private StepPerformer m_stepPerformer;
|
|
|
|
protected override void Awake()
|
|
{
|
|
Instance = this;
|
|
gameObject.SetActiveEx(false);
|
|
|
|
m_stepPerformer = new StepPerformer(this);
|
|
|
|
menus.Add(new InGameUI_SaveState(this));
|
|
menus.Add(new InGameUI_LoadState(this));
|
|
menus.Add(new InGameUI_QuitGame(this));
|
|
|
|
base.Awake();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
/// <summary> 괏닸우醵우亮 </summary>
|
|
public void SaveQuickState(object state)
|
|
{
|
|
m_state = state;
|
|
}
|
|
/// <summary>
|
|
/// 뗍혤우醵우亮
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <returns></returns>
|
|
public object GetQuickState()
|
|
{
|
|
return m_state;
|
|
}
|
|
|
|
public void Show(RomFile currentRom, IEmuCore core)
|
|
{
|
|
m_state = null;//헌왕踏狗우亮
|
|
CommandDispatcher.Instance.RegistController(this);
|
|
|
|
m_rom = currentRom;
|
|
Core = core;
|
|
m_stepPerformer.Reset();
|
|
|
|
if (App.user.IsLoggedIn && !App.roomMgr.InRoom)
|
|
{
|
|
App.roomMgr.SendCreateRoom(m_rom.ID, 0, m_rom.Hash);
|
|
}
|
|
|
|
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomWaitStepChange, OnServerStepUpdate);
|
|
OptionUI.Instance.OnHide += PopMenu_OnHide;
|
|
|
|
gameObject.SetActiveEx(true);
|
|
}
|
|
|
|
private void OnServerStepUpdate(int step)
|
|
{
|
|
m_stepPerformer.Perform(step);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
CommandDispatcher.Instance.UnRegistController(this);
|
|
|
|
OptionUI.Instance.OnHide -= PopMenu_OnHide;
|
|
gameObject.SetActiveEx(false);
|
|
}
|
|
|
|
protected override void OnCmdOptionMenu()
|
|
{
|
|
OptionUI.Instance.Pop(menus);
|
|
|
|
if (!IsNetPlay)//데훙친駕董界친콰포
|
|
{
|
|
Core.Pause();
|
|
}
|
|
}
|
|
|
|
//꽉데밑균珂빅
|
|
private void PopMenu_OnHide()
|
|
{
|
|
if (!IsNetPlay)//데훙친駕뿟릿친콰포돨董界
|
|
Core.Resume();
|
|
}
|
|
|
|
|
|
public void QuitGame()
|
|
{
|
|
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomWaitStepChange, OnServerStepUpdate);
|
|
App.roomMgr.SendLeavnRoom();
|
|
App.emu.StopGame();
|
|
|
|
ControlScheme.Current = ControlSchemeSetts.Normal;
|
|
}
|
|
}
|
|
}
|