2024-09-13 13:28:33 +08:00
|
|
|
|
using AxibugEmuOnline.Client.ClientCore;
|
2024-11-07 17:58:20 +08:00
|
|
|
|
using MyNes.Core;
|
2024-09-13 13:28:33 +08:00
|
|
|
|
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;
|
2024-11-07 17:58:20 +08:00
|
|
|
|
private IEmuCore m_emuCore;
|
2024-09-14 15:32:29 +08:00
|
|
|
|
|
2024-09-13 13:28:33 +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
|
|
|
|
|
2024-09-13 13:28:33 +08:00
|
|
|
|
switch (romFile.Platform)
|
|
|
|
|
{
|
|
|
|
|
case EnumPlatform.NES:
|
2024-11-07 17:58:20 +08:00
|
|
|
|
m_emuCore = GameObject.Instantiate(Resources.Load<GameObject>("NES/NesEmulator")).GetComponent<IEmuCore>();
|
2024-09-13 13:28:33 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2024-11-07 17:58:20 +08:00
|
|
|
|
|
|
|
|
|
m_emuInstance = m_emuCore.gameObject;
|
|
|
|
|
|
|
|
|
|
m_emuCore.StartGame(romFile);
|
|
|
|
|
LaunchUI.Instance.HideMainMenu();
|
|
|
|
|
InGameUI.Instance.Show(romFile, m_emuCore);
|
|
|
|
|
|
|
|
|
|
m_emuCore.SetupScheme();
|
2024-09-13 13:28:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-13 13:28:33 +08:00
|
|
|
|
|
2024-09-14 15:32:29 +08:00
|
|
|
|
InGameUI.Instance.Hide();
|
|
|
|
|
LaunchUI.Instance.ShowMainMenu();
|
2024-11-07 17:58:20 +08:00
|
|
|
|
|
|
|
|
|
ControlScheme.Current = ControlSchemeSetts.Normal;
|
2024-09-13 13:28:33 +08:00
|
|
|
|
}
|
2024-07-03 14:43:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|