AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs

45 lines
1.2 KiB
C#
Raw Normal View History

using AxibugEmuOnline.Client.ClientCore;
using MyNes.Core;
using UnityEngine;
namespace AxibugEmuOnline.Client.Manager
2024-07-03 14:43:11 +08:00
{
2024-08-16 10:20:00 +08:00
public class AppEmu
2024-07-04 21:06:41 +08:00
{
2024-09-14 15:32:29 +08:00
private GameObject m_emuInstance;
private IEmuCore m_emuCore;
2024-09-14 15:32:29 +08:00
public void BeginGame(RomFile romFile)
{
2024-09-14 15:32:29 +08:00
if (m_emuInstance != null) return;
2024-08-16 10:20:00 +08:00
switch (romFile.Platform)
{
case EnumPlatform.NES:
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()
{
2024-09-14 15:32:29 +08:00
if (m_emuInstance == null) return;
GameObject.Destroy(m_emuInstance);
m_emuInstance = null;
2024-09-14 15:32:29 +08:00
InGameUI.Instance.Hide();
LaunchUI.Instance.ShowMainMenu();
ControlScheme.Current = ControlSchemeSetts.Normal;
}
2024-07-03 14:43:11 +08:00
}
}