Skip to content

Commit

Permalink
Fix crash in campaign 4 boss
Browse files Browse the repository at this point in the history
  • Loading branch information
lotuuu committed Jun 11, 2024
1 parent 6ac64a0 commit 7c2c6f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/Assets/Scripts/Battle/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void HandleBattleResult(bool result)

// This should be handled differently
CampaignManager.selectedCampaignData.levels.Find(level => level.id == LevelProgress.selectedLevelData.id).status = LevelProgress.Status.Completed;
if (CampaignManager.selectedCampaignData.levels.Any(level => level.id == LevelProgress.nextLevelData.id))
if (LevelProgress.nextLevelData != null && CampaignManager.selectedCampaignData.levels.Any(level => level.id == LevelProgress.nextLevelData.id))
{
CampaignManager.selectedCampaignData.levels.Find(level => level.id == LevelProgress.nextLevelData.id).status = LevelProgress.Status.Unlocked;
}
Expand Down Expand Up @@ -318,6 +318,12 @@ private Dictionary<string, int> GetLevelRewards()
private void SetUpNextButton()
{
GameObject nextButton = victorySplash.transform.Find("Next").gameObject;
if (LevelProgress.nextLevelData == null)
{
nextButton.SetActive(false);
return;
}
else
if (LevelProgress.selectedLevelData.campaignId != LevelProgress.nextLevelData.campaignId)
{
nextButton.GetComponentInChildren<TMP_Text>().text = "NEXT CAMPAIGN";
Expand Down

0 comments on commit 7c2c6f0

Please sign in to comment.