/// <summary> /// 获得禁用的图标,有可能没有 /// </summary> /// <returns></returns> public virtual Sprite GetDisIcon() { if (!Icon.IsInvStr()) { return(GRMgr.GetIcon(Icon + BaseConstMgr.Suffix_Disable)); } return(GRMgr.GetIcon(TDID + BaseConstMgr.Suffix_Disable)); }
/// <summary> /// prefab /// </summary> /// <returns></returns> public virtual GameObject GetPrefab() { if (!Prefab.IsInvStr()) { return(GRMgr.GetPrefab(Prefab)); } return(GRMgr.GetPrefab(TDID)); }
/// <summary> /// 获取icon /// </summary> /// <returns></returns> public virtual Sprite GetIcon() { if (!Icon.IsInvStr()) { return(GRMgr.GetIcon(Icon)); } return(GRMgr.GetIcon(TDID)); }
public static void Quit() { if (!Application.isEditor) { GRMgr.UnLoadLoadedAssetBundle(); Process.GetCurrentProcess().Kill(); Application.Quit(); Environment.Exit(0); } }
public override Sprite GetIcon() { var ret = GRMgr.GetIcon(BaseConstMgr.Prefix_Attr + TDID); if (ret == null) { ret = base.GetIcon(); } return(ret); }
// 加载战场 // readData:是否读取数据 IEnumerator <float> _LoadBattle() { yield return(Timing.WaitForOneFrame); Callback_OnBattleLoadStart?.Invoke(); float startTime = Time.realtimeSinceStartup; IsLoadingBattle = true; IsLoadBattleEnd = false; IsGameStart = false; //开始Tip SubBattleCoroutine.Run(_RandTip()); //开始加载 Callback_OnBattleLoad?.Invoke(); yield return(Timing.WaitForOneFrame); OnLoadSceneStart(); Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.0f); //演示几秒,给UI渐变的时间 yield return(Timing.WaitForSeconds(DelayLoadSceneTime)); //加载场景 SceneName = CurData.GetRawSceneName(); SceneAsset = GRMgr.LoadScene(SceneName); while (!SceneAsset.IsDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("LoadingScene", SceneAsset.Progress * 0.8f); } //延时一帧 yield return(Timing.WaitForOneFrame); SceneManager.SetActiveScene(SceneManager.GetSceneByName(SceneName)); Callback_OnBattleLoadedScene?.Invoke(); //这里必须延迟一帧,等待UI创建,注册事件 yield return(Timing.WaitForOneFrame); GC.Collect(); Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); IsLoadingBattle = false; //场景加载结束 Callback_OnBattleLoaded?.Invoke(); IsLoadBattleEnd = true; Callback_OnGameStart?.Invoke(); IsGameStart = true; }
// 卸载战场 IEnumerator <float> _UnLoadBattle(Callback onDone) { if (CurData == null) { yield break; } IsLoadingBattle = false; IsLoadBattleEnd = false; IsGameStart = false; CurData.OnBeRemoved(); CurData = null; yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoad?.Invoke(); yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f); //延时一秒.防止UI卡住 yield return(Timing.WaitForSeconds(0.3f)); var wait = SceneManager.UnloadSceneAsync(SceneName); while (!wait.isDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress); } //卸载未使用的资源 GRMgr.UnloadScene(SceneAsset); Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); BaseGlobal.ResumeGame(); yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoaded?.Invoke(); onDone?.Invoke(); }
// 卸载战场 IEnumerator <float> _unLoadBattle(Callback onDone) { IsLoadedScene = false; IsLoadingBattle = false; IsLoadBattleEnd = false; IsGameStartOver = false; IsInPauseLoadingView = false; CurData.OnBeRemoved(); CurData = null; //暂停一段时间 BaseGlobal.PauseGame(true); BaseInputMgr.ResetFullScreenState(); Callback_OnBattleUnLoad?.Invoke(); yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f); //延时一秒.防止UI卡住 yield return(Timing.WaitForSeconds(0.5f)); var wait = SceneManager.UnloadSceneAsync(SceneName); while (!wait.isDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress); } //卸载未使用的资源 GRMgr.UnloadScene(SceneAsset); Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoaded?.Invoke(); BaseGlobal.ResumeGame(); onDone?.Invoke(); }
public Sprite GetBg() { return(GRMgr.GetIcon(Bg)); }
/// <summary> /// 获得animator /// </summary> /// <returns></returns> public virtual RuntimeAnimatorController GetAnimator() { return(GRMgr.GetAnimator(TDID)); }
// 加载战场 // readData:是否读取数据 IEnumerator <float> _loadBattle(bool readData = true) { BaseGlobal.ResumeGame(); BaseInputMgr.ResetFullScreenState(); Callback_OnBattleLoadStart?.Invoke(); yield return(Timing.WaitForOneFrame); float startTime = Time.realtimeSinceStartup; IsLoadedScene = false; IsLoadingBattle = true; IsLoadBattleEnd = false; IsGameStartOver = false; IsGameStart = false; IsInPauseLoadingView = false; //开始Tip BattleCoroutine.Run(_randTip()); //开始加载 Callback_OnBattleLoad?.Invoke(); yield return(Timing.WaitForOneFrame); OnLoadSceneStart(); Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("StartToLoad"), 0.0f); //演示几秒,给UI渐变的时间 yield return(Timing.WaitForSeconds(DelayLoadSceneTime)); //加载场景 SceneName = CurData.GetSceneName(); SceneAsset = GRMgr.LoadScene(SceneName); while (!SceneAsset.IsDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("LoadingScene"), SceneAsset.Progress * 0.8f); } //延时一帧 yield return(Timing.WaitForOneFrame); Scene = SceneManager.GetSceneByName(SceneName); SceneManager.SetActiveScene(Scene); IsLoadedScene = true; Callback_OnBattleLoadedScene?.Invoke(); if (BaseSceneObject == null) { CLog.Error("错误,场景里没有SceneObject"); } //这里必须延迟一帧,等待UI创建,注册事件 yield return(Timing.WaitForOneFrame); //读取数据前,资源加载 yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BeforeReadData()))); Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("BeforeReadData"), 0.9f); if (readData) { BaseGlobal.IsUnReadData = false; //读取战场数据 BaseGlobal.DBMgr.ReadGameDBData(); BaseGlobal.IsUnReadData = true; } yield return(Timing.WaitForOneFrame); Callback_OnBattleReadDataEnd?.Invoke(); //增加加载战场次数 LoadBattleCount++; //读取数据后资源加载 yield return(Timing.WaitUntilDone(BattleCoroutine.Run(AffterReadData()))); Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("AffterReadData"), 0.95f); while (IsInCustomLoading) { yield return(Timing.WaitForOneFrame); } GC.Collect(); Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("GC"), 1.0f); IsLoadingBattle = false; //场景加载结束 Callback_OnBattleLoaded?.Invoke(); IsLoadBattleEnd = true; yield return(Timing.WaitForOneFrame); //游戏开始(预处理最后阶段) SelfBaseGlobal.OnGameStart1(); SelfBaseGlobal.OnGameStart2(); Callback_OnGameStart?.Invoke(); yield return(Timing.WaitForOneFrame); SelfBaseGlobal.OnGameStarted1(); SelfBaseGlobal.OnGameStarted2(); Callback_OnGameStarted?.Invoke(); IsGameStart = true; //暂停在加载界面 Callback_OnInPauseLoadingView?.Invoke(); IsInPauseLoadingView = NeedPauseLoading; while (IsInPauseLoadingView) { yield return(Timing.WaitForOneFrame); } SelfBaseGlobal.OnCloseLoadingView(); Callback_OnCloseLoadingView?.Invoke(); //锁定进入战场流程 while (IsLockBattleStartFlow) { yield return(Timing.WaitForOneFrame); } yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BattleStart()))); //进入自定义流程的时候暂停 Callback_OnStartCustomBattleCoroutine?.Invoke(); if (PlotMgr != null) { PlotMgr?.SetPlotPause(true); yield return(Timing.WaitUntilDone(PlotMgr.CustomStartBattleCoroutine())); PlotMgr?.SetPlotPause(false); } Callback_OnEndCustomBattleCoroutine.Invoke(); //结尾部分 SelfBaseGlobal.OnGameStartOver(); Callback_OnGameStartOver?.Invoke(); IsGameStartOver = true; }