using System; using Cysharp.Threading.Tasks; using Game.Boss; using Game.Pathfinding; using Game.Player; using Game.RayCast; using Game.Room; using TMPro; using UnityEngine; using UnityEngine.Serialization; namespace Game { public class Game : MonoBehaviour { private static Game _game; private GameObject _self => gameObject; private UIManager _uiManager; private ResourceManager _resourceManager; private ProcedureManager _procedureManager; private PlayerManager _playerManager; private BFSManager _bfsManager; private RoomManager _roomManager; private MouseInputManager _mouseInputManager; private BossManager _bossManager; [SerializeField] private LoadType _loadType1 = LoadType.Editor; [SerializeField] private float time; public static GameObject self => _game._self; public static IProcedureManager procedureManager => _game._procedureManager; public static IResourceManager resourceManager => _game._resourceManager; public static IUIManager uiManager => _game._uiManager; public static IPlayerManager playerManager => _game._playerManager; public static IBFSManager bfsManager => _game._bfsManager; public static IRoomManager roomManager => _game._roomManager; public static IMouseInputManager mouseInputManager => _game._mouseInputManager; public static IBossManager bossManager => _game._bossManager; private void Awake() { _game = this; DontDestroyOnLoad(this.gameObject); AssemblyManager.Initialize(); this._uiManager = new UIManager(); this._resourceManager = new ResourceManager(); this._procedureManager = new ProcedureManager(); this._playerManager = new PlayerManager(); this._bfsManager = new BFSManager(); this._roomManager = new RoomManager(); this._mouseInputManager = new MouseInputManager(); this._bossManager = new BossManager(); this._resourceManager.Init(); this._uiManager.Init(); this._procedureManager.Init(); this._playerManager.Init(); this._bfsManager.Init(); this._roomManager.Init(); this._mouseInputManager.Init(); this._bossManager.Init(); } private void Start() { UniTask.Create( async () => { await _resourceManager.InitLoadModeAsync(_loadType1); Game.uiManager.CreateUI(UIType.GlobalLogOnlyAppUI, UILayer.High); Game.uiManager.ShowUI(UIType.GlobalLogOnlyAppUI); CommonHelper.AddAppLog("asset init finish!"); this.OnCreateUI(); this._procedureManager.StartProcedure(ProcedureType.LoadingGameSceneProcedure); return "11"; }).Forget(); } private void OnCreateUI() { CommonHelper.AddAppLog("start create ui !"); Game.uiManager.CreateUI(UIType.InputNameUI, UILayer.Mid); Game.uiManager.CreateUI(UIType.GameSceneHelpUI, UILayer.High); Game.uiManager.CreateUI(UIType.GameSceneMainUI, UILayer.Low); CommonHelper.AddAppLog("create ui finish !"); } private void Update() { time = Time.deltaTime; this._resourceManager.Update(time); this._uiManager.Update(time); this._procedureManager.Update(time); this._bfsManager.Update(time); this._playerManager.Update(time); this._roomManager.Update(time); this._bossManager.Update(this.time); } private void OnDestroy() { this._resourceManager.Dispose(); this._uiManager.Dispose(); this._procedureManager.Dispose(); this._bfsManager.Dispose(); this._playerManager.Dispose(); this._roomManager.Dispose(); this._bossManager.Dispose(); } } }