From 7c2c6f0172e4b6924d9189a9ecf4c4040650a222 Mon Sep 17 00:00:00 2001 From: lotuuu Date: Tue, 11 Jun 2024 10:32:24 -0300 Subject: [PATCH] Fix crash in campaign 4 boss --- client/Assets/Scripts/Battle/BattleManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/Assets/Scripts/Battle/BattleManager.cs b/client/Assets/Scripts/Battle/BattleManager.cs index f2bf1e5d..111f7032 100644 --- a/client/Assets/Scripts/Battle/BattleManager.cs +++ b/client/Assets/Scripts/Battle/BattleManager.cs @@ -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; } @@ -318,6 +318,12 @@ private Dictionary 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().text = "NEXT CAMPAIGN";