2024-07-12 13:33:45 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace ZC
|
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
public class ZCGame : MonoBehaviour, IBehaviour
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
|
|
|
private GameObject _self;
|
2024-07-19 10:51:48 +08:00
|
|
|
private Transform _objectPool;
|
2024-11-12 16:57:51 +08:00
|
|
|
private float _gameTime;
|
|
|
|
private bool _isPause;
|
|
|
|
private bool _isActive;
|
|
|
|
private bool _isDisposed;
|
|
|
|
|
|
|
|
public long Id { get; }
|
|
|
|
|
|
|
|
public bool isDisposed => _isDisposed;
|
|
|
|
|
|
|
|
public bool isPause => _isPause;
|
|
|
|
|
|
|
|
public bool isActive => _isActive;
|
2024-07-12 13:33:45 +08:00
|
|
|
|
|
|
|
public static ZCGame _zcGame;
|
2024-07-19 10:51:48 +08:00
|
|
|
private ObjectManager _objectManager;
|
|
|
|
private UIManager _uiManager;
|
|
|
|
private ProcedureManager _procedureManager;
|
2024-07-19 14:52:57 +08:00
|
|
|
private ConfigManager _configManager;
|
2024-07-12 13:33:45 +08:00
|
|
|
|
|
|
|
public static GameObject Self => _zcGame._self;
|
2024-07-19 10:51:48 +08:00
|
|
|
public static Transform ObjectPool => _zcGame._objectPool;
|
2024-11-12 16:57:51 +08:00
|
|
|
public static float GameTime => _zcGame._gameTime;
|
2024-07-12 13:33:45 +08:00
|
|
|
|
2024-07-19 10:51:48 +08:00
|
|
|
public static IObjectManager ObjectManager => _zcGame._objectManager;
|
|
|
|
public static IUIManager UIManager => _zcGame._uiManager;
|
|
|
|
public static IProcedureManager ProcedureManager => _zcGame._procedureManager;
|
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
#region Mono
|
2024-07-19 10:51:48 +08:00
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
private void Update()
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
_gameTime += Time.deltaTime;
|
|
|
|
OnUpdate(_gameTime);
|
2024-07-12 13:33:45 +08:00
|
|
|
}
|
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
private void OnDestroy()
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
OnDispose();
|
2024-07-12 13:33:45 +08:00
|
|
|
}
|
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
#endregion
|
2024-07-12 13:33:45 +08:00
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
public void OnInit(params object[] data)
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
var self = data[0] as GameObject;
|
|
|
|
_zcGame = this;
|
|
|
|
this._self = self;
|
|
|
|
this._objectPool = self.transform.Find("ObjectPool");
|
|
|
|
this._isDisposed = false;
|
|
|
|
this._isPause = false;
|
|
|
|
AssemblyManager.Initialize();
|
|
|
|
|
2024-07-19 10:51:48 +08:00
|
|
|
this._objectManager = new ObjectManager();
|
2024-11-12 16:57:51 +08:00
|
|
|
this._objectManager.OnInit(data);
|
2024-07-12 13:33:45 +08:00
|
|
|
|
2024-07-19 10:51:48 +08:00
|
|
|
this._uiManager = new UIManager();
|
|
|
|
this._procedureManager = new ProcedureManager();
|
2024-07-19 14:52:57 +08:00
|
|
|
this._configManager = new ConfigManager();
|
2024-07-19 10:51:48 +08:00
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
_uiManager.OnInit(data);
|
|
|
|
_procedureManager.OnInit(data);
|
|
|
|
_configManager.OnInit(data);
|
2024-07-19 10:51:48 +08:00
|
|
|
|
|
|
|
this._procedureManager.ChangeProcedure(ProcedureType.LoadingGameSceneProcedure);
|
|
|
|
}
|
2024-07-15 16:30:56 +08:00
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
public void OnUpdate(float time, params object[] data)
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
if (this.isPause) return;
|
|
|
|
|
|
|
|
this._uiManager.OnUpdate(time, data);
|
|
|
|
this._procedureManager.OnUpdate(time, data);
|
|
|
|
_objectManager.OnUpdate(time, data);
|
2024-07-12 13:33:45 +08:00
|
|
|
}
|
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
public void OnPause(params object[] data)
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
this._isPause = true;
|
|
|
|
|
|
|
|
_uiManager.OnPause(data);
|
|
|
|
_configManager.OnPause(data);
|
|
|
|
_objectManager.OnPause(data);
|
|
|
|
_procedureManager.OnPause(data);
|
2024-07-12 13:33:45 +08:00
|
|
|
}
|
|
|
|
|
2024-11-12 16:57:51 +08:00
|
|
|
public void OnResume(params object[] data)
|
2024-07-12 13:33:45 +08:00
|
|
|
{
|
2024-11-12 16:57:51 +08:00
|
|
|
this._isPause = false;
|
|
|
|
|
|
|
|
_uiManager.OnResume(data);
|
|
|
|
_configManager.OnResume(data);
|
|
|
|
_objectManager.OnResume(data);
|
|
|
|
_procedureManager.OnResume(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnDispose(params object[] data)
|
|
|
|
{
|
|
|
|
_isActive = false;
|
|
|
|
_isPause = true;
|
|
|
|
_isDisposed = true;
|
|
|
|
|
|
|
|
this._objectManager.OnDispose(data);
|
|
|
|
_uiManager.OnDispose(data);
|
|
|
|
_configManager.OnDispose(data);
|
|
|
|
_procedureManager.OnDispose(data);
|
|
|
|
ResourcesLocalComponent.Instance.OnDispose();
|
|
|
|
|
2024-07-12 13:33:45 +08:00
|
|
|
Debug.Log("关闭应用了");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|