using System; using LuaInterface; using UnityEngine; using UnityEngine.SceneManagement; namespace MoleMole { public static class GeneralLogicManager { private static bool _initialized; private static readonly string UI_DEFAULT_SHADER_NAME = "miHoYo/UI/Default"; public static void InitAll() { InitOnGameStart(); InitOnDataAssetReady(); } public static void InitOnGameStart() { if (_initialized) { DestroyAll(); } _initialized = true; CommonUtils.commonFileReader = Miscs.LoadTextFileToString; LuaStatic.luaFileReader = Miscs.LoadTextFileToString; LocalizationGeneralLogic.InitOnGameStart(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Shader shader = Shader.Find(UI_DEFAULT_SHADER_NAME); if (shader == null) { } Canvas.GetDefaultCanvasMaterial().shader = shader; GraphicsUtils.SetShaderBloomMaxBlendParams(); Singleton.Instance.SetupApkCommentInfo(); Singleton.Instance.manager.Init(); } public static void InitOnDataAssetReady(bool async = false, Action refreshFinishNecessarCallback = null) { if (async) { GlobalDataManager.RefreshAsync(delegate { DoAfterRefreshGlobalData(); if (refreshFinishNecessarCallback != null) { refreshFinishNecessarCallback(); } }); } else { GlobalDataManager.Refresh(); DoAfterRefreshGlobalData(); if (refreshFinishNecessarCallback != null) { refreshFinishNecessarCallback(); } } } private static void DoAfterRefreshGlobalData() { LocalizationGeneralLogic.InitOnDataAssetReady(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); Singleton.Create(); } public static void RestartGame() { if (Singleton.Instance != null && Singleton.Instance.SceneCanvas != null) { MonoGameEntry monoGameEntry = Singleton.Instance.SceneCanvas as MonoGameEntry; if (monoGameEntry != null) { monoGameEntry.OnRestartGame(); } } Singleton.Instance.StopAll(); Singleton.Instance.ClearUp(); SceneManager.LoadScene("GameEntry"); } public static void QuitGame() { Application.Quit(); } public static void DestroyAll() { Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); if (Singleton.Instance != null) { Singleton.Destroy(); } Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); Singleton.Instance.Destroy(); Singleton.Destroy(); } } }