From 276eed0f3c5c5b57221fae0950feee3bedbe3d7e Mon Sep 17 00:00:00 2001 From: yangjing Date: Fri, 11 Feb 2022 21:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E4=B8=80=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Game/GameLogic.cs | 4 ++-- Assets/Scripts/Storage/PlayerData.cs | 28 ++++++++++++++++++++++++++++ Assets/Scripts/UI/PanelResult.cs | 6 +++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Game/GameLogic.cs b/Assets/Scripts/Game/GameLogic.cs index c1dda20a..ef90ec6b 100644 --- a/Assets/Scripts/Game/GameLogic.cs +++ b/Assets/Scripts/Game/GameLogic.cs @@ -70,11 +70,11 @@ public class GameLogic : MonoBehaviour { PlayerData.Instance.UnlockNewLevel(); } - tUIResult.Init(PlayerData.Instance.CurrentLevelID, tEdData.EndingName, tEdData.IsGoodEnding, tHasNew, PlayerData.Instance.HasUnlockedAllLevel()); + tUIResult.Init(PlayerData.Instance.CurrentLevelID, tEdData.EndingName, tEdData.IsGoodEnding, tHasNew, PlayerData.Instance.IsNextLevelPassed()); } else { - tUIResult.Init(PlayerData.Instance.CurrentLevelID, "", false, false, PlayerData.Instance.HasUnlockedAllLevel()); + tUIResult.Init(PlayerData.Instance.CurrentLevelID, "", false, false, PlayerData.Instance.IsNextLevelPassed()); } tUIResult.DelAgain = PlayAgain; diff --git a/Assets/Scripts/Storage/PlayerData.cs b/Assets/Scripts/Storage/PlayerData.cs index 0d4e825f..e5aae501 100644 --- a/Assets/Scripts/Storage/PlayerData.cs +++ b/Assets/Scripts/Storage/PlayerData.cs @@ -51,6 +51,17 @@ public class PlayerData : StorageBase return mUnlockedLevel == GameConfig.Instance.LevelSort.Count; } + public bool IsNextLevelPassed() + { + if (mCurrentLevel == GameConfig.Instance.LevelSort.Count) + { + return true; + } + + int tNextLvID = GameConfig.Instance.LevelSort[mCurrentLevel];//+1 - 1 + return LevelReachGoodEnding(tNextLvID); + } + public bool AddEnding(int pLevelID, int pEndingID) { if (!mEndingDic.ContainsKey(pLevelID)) @@ -78,6 +89,23 @@ public class PlayerData : StorageBase return 0; } + public bool LevelReachGoodEnding(int pLevelID) + { + if (mEndingDic.ContainsKey(pLevelID)) + { + LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID); + for (int i = 0; i < tLvData.Endings.Count; i++) + { + if (tLvData.Endings[i].IsGoodEnding && mEndingDic[pLevelID].Contains(i)) + { + return true; + } + } + } + + return false; + } + public bool HasUnlockedEnding(int pLevelID, int pEndingID) { return mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID); diff --git a/Assets/Scripts/UI/PanelResult.cs b/Assets/Scripts/UI/PanelResult.cs index a6628b81..58a06bd2 100644 --- a/Assets/Scripts/UI/PanelResult.cs +++ b/Assets/Scripts/UI/PanelResult.cs @@ -45,7 +45,7 @@ public class PanelResult : BasePanel mGobFx.SetActive(pFocus); } - public void Init(int pLevelID, string pEndingName,bool pIsWin, bool pHasNew, bool pAllLevelClear) + public void Init(int pLevelID, string pEndingName,bool pIsWin, bool pHasNew, bool pNextLevelClear) { mTxtEndingName.text = pEndingName; @@ -55,8 +55,8 @@ public class PanelResult : BasePanel mGobWinFace.SetActive(pIsWin); mGobLoseFace.SetActive(!pIsWin); - mGobWinBtns.SetActive(!pAllLevelClear && pIsWin); - mGobOtherBtns.SetActive(pAllLevelClear || !pIsWin); + mGobWinBtns.SetActive(!pNextLevelClear && pIsWin); + mGobOtherBtns.SetActive(pNextLevelClear || !pIsWin); LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID); mBtnEndings.Init(pLevelID, PlayerData.Instance.EndingCountOfLevel(pLevelID), tLvData.Endings.Count);