forked from sin365/AxibugEmuOnline
IEmuCore接口增加获取gameObject的方法,完善游戏中和UI操作的操作集切换功能
This commit is contained in:
parent
b66df94086
commit
88313eee6b
@ -6,12 +6,15 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public interface IEmuCore
|
||||
{
|
||||
GameObject gameObject { get; }
|
||||
|
||||
object GetState();
|
||||
byte[] GetStateBytes();
|
||||
void LoadState(object state);
|
||||
void LoadStateFromBytes(byte[] data);
|
||||
void Pause();
|
||||
void Resume();
|
||||
void SetupScheme();
|
||||
void SetupScheme();
|
||||
void StartGame(RomFile romFile);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using MyNes.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.Manager
|
||||
@ -6,6 +7,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
public class AppEmu
|
||||
{
|
||||
private GameObject m_emuInstance;
|
||||
private IEmuCore m_emuCore;
|
||||
|
||||
public void BeginGame(RomFile romFile)
|
||||
{
|
||||
@ -14,14 +16,17 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
switch (romFile.Platform)
|
||||
{
|
||||
case EnumPlatform.NES:
|
||||
var nesEmu = GameObject.Instantiate(Resources.Load<GameObject>("NES/NesEmulator")).GetComponent<NesEmulator>();
|
||||
m_emuInstance = nesEmu.gameObject;
|
||||
|
||||
nesEmu.StartGame(romFile);
|
||||
LaunchUI.Instance.HideMainMenu();
|
||||
InGameUI.Instance.Show(romFile, nesEmu);
|
||||
m_emuCore = GameObject.Instantiate(Resources.Load<GameObject>("NES/NesEmulator")).GetComponent<IEmuCore>();
|
||||
break;
|
||||
}
|
||||
|
||||
m_emuInstance = m_emuCore.gameObject;
|
||||
|
||||
m_emuCore.StartGame(romFile);
|
||||
LaunchUI.Instance.HideMainMenu();
|
||||
InGameUI.Instance.Show(romFile, m_emuCore);
|
||||
|
||||
m_emuCore.SetupScheme();
|
||||
}
|
||||
|
||||
public void StopGame()
|
||||
@ -32,6 +37,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
|
||||
InGameUI.Instance.Hide();
|
||||
LaunchUI.Instance.ShowMainMenu();
|
||||
|
||||
ControlScheme.Current = ControlSchemeSetts.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,12 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
}
|
||||
|
||||
//键位映射表需要在按键响应的堆栈结束后处理,防止迭代器修改问题
|
||||
if (m_waitMapperSetting != null)
|
||||
{
|
||||
m_keyMapper = m_waitMapperSetting;
|
||||
m_waitMapperSetting = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<KeyCode, EnumCommand> m_waitMapperSetting = null;
|
||||
|
@ -12,7 +12,7 @@ namespace AxibugEmuOnline.Client
|
||||
public override bool Enable => gameObject.activeInHierarchy;
|
||||
|
||||
/// <summary> 指示该游戏实例是否处于联网模式 </summary>
|
||||
public bool IsOnline => App.roomMgr.RoomState > AxibugProtobuf.RoomGameState.OnlyHost;
|
||||
public bool IsOnline => App.user.IsLoggedIn ? App.roomMgr.RoomState > AxibugProtobuf.RoomGameState.OnlyHost : false;
|
||||
|
||||
private RomFile m_rom;
|
||||
public IEmuCore Core { get; private set; }
|
||||
@ -57,6 +57,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void Show(RomFile currentRom, IEmuCore core)
|
||||
{
|
||||
m_state = null;//清空游戏快照
|
||||
CommandDispatcher.Instance.RegistController(this);
|
||||
|
||||
m_rom = currentRom;
|
||||
@ -69,6 +70,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomWaitStepChange, OnServerStepUpdate);
|
||||
OptionUI.Instance.OnHide += PopMenu_OnHide;
|
||||
|
||||
gameObject.SetActiveEx(true);
|
||||
}
|
||||
@ -82,14 +84,28 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
CommandDispatcher.Instance.UnRegistController(this);
|
||||
|
||||
OptionUI.Instance.OnHide -= PopMenu_OnHide;
|
||||
gameObject.SetActiveEx(false);
|
||||
}
|
||||
|
||||
protected override void OnCmdOptionMenu()
|
||||
{
|
||||
OptionUI.Instance.Pop(menus);
|
||||
|
||||
if (!IsOnline)//单人模式暂停模拟器
|
||||
{
|
||||
Core.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
//菜单关闭时候
|
||||
private void PopMenu_OnHide()
|
||||
{
|
||||
if (!IsOnline)//单人模式恢复模拟器的暂停
|
||||
Core.Resume();
|
||||
}
|
||||
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomWaitStepChange, OnServerStepUpdate);
|
||||
|
@ -24,6 +24,8 @@ namespace AxibugEmuOnline.Client
|
||||
private bool m_bPoped = false;
|
||||
private List<OptionUI_MenuItem> m_runtimeMenuItems = new List<OptionUI_MenuItem>();
|
||||
|
||||
public event Action OnHide;
|
||||
|
||||
private int m_selectIndex = -1;
|
||||
public int SelectIndex
|
||||
{
|
||||
@ -178,6 +180,8 @@ namespace AxibugEmuOnline.Client
|
||||
m_bPoped = false;
|
||||
|
||||
ControlScheme.Current = m_lastCS;
|
||||
|
||||
OnHide?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user