修改下一关逻辑

This commit is contained in:
yangjing 2022-02-11 21:04:38 +08:00
parent c3777e222a
commit 276eed0f3c
3 changed files with 33 additions and 5 deletions

View File

@ -70,11 +70,11 @@ public class GameLogic : MonoBehaviour
{ {
PlayerData.Instance.UnlockNewLevel(); 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 else
{ {
tUIResult.Init(PlayerData.Instance.CurrentLevelID, "", false, false, PlayerData.Instance.HasUnlockedAllLevel()); tUIResult.Init(PlayerData.Instance.CurrentLevelID, "", false, false, PlayerData.Instance.IsNextLevelPassed());
} }
tUIResult.DelAgain = PlayAgain; tUIResult.DelAgain = PlayAgain;

View File

@ -51,6 +51,17 @@ public class PlayerData : StorageBase<PlayerData>
return mUnlockedLevel == GameConfig.Instance.LevelSort.Count; 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) public bool AddEnding(int pLevelID, int pEndingID)
{ {
if (!mEndingDic.ContainsKey(pLevelID)) if (!mEndingDic.ContainsKey(pLevelID))
@ -78,6 +89,23 @@ public class PlayerData : StorageBase<PlayerData>
return 0; 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) public bool HasUnlockedEnding(int pLevelID, int pEndingID)
{ {
return mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID); return mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID);

View File

@ -45,7 +45,7 @@ public class PanelResult : BasePanel
mGobFx.SetActive(pFocus); 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; mTxtEndingName.text = pEndingName;
@ -55,8 +55,8 @@ public class PanelResult : BasePanel
mGobWinFace.SetActive(pIsWin); mGobWinFace.SetActive(pIsWin);
mGobLoseFace.SetActive(!pIsWin); mGobLoseFace.SetActive(!pIsWin);
mGobWinBtns.SetActive(!pAllLevelClear && pIsWin); mGobWinBtns.SetActive(!pNextLevelClear && pIsWin);
mGobOtherBtns.SetActive(pAllLevelClear || !pIsWin); mGobOtherBtns.SetActive(pNextLevelClear || !pIsWin);
LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID); LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID);
mBtnEndings.Init(pLevelID, PlayerData.Instance.EndingCountOfLevel(pLevelID), tLvData.Endings.Count); mBtnEndings.Init(pLevelID, PlayerData.Instance.EndingCountOfLevel(pLevelID), tLvData.Endings.Count);