Create BattleResult

This commit is contained in:
henriquenakashima 2020-09-26 23:10:36 -04:00
parent 0d7f4f4954
commit 84782a9bb3
4 changed files with 46 additions and 4 deletions

View file

@ -389,11 +389,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
foreach (BattleParticipant p in this.monsters) {
p.CheckState();
}
if (System.Array.TrueForAll(this.heroes, h => !h.IsAlive())) {
Debug.Log("You lost!");
}
if (System.Array.TrueForAll(this.monsters, m => !m.IsAlive())) {
Debug.Log("You won!");
BattleResult.FinishBattle(new BattleResult(false));
} else if (System.Array.TrueForAll(this.monsters, m => !m.IsAlive())) {
BattleResult.FinishBattle(new BattleResult(true));
}
}

View file

@ -0,0 +1,30 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class BattleResult {
private static BattleResult sResult;
private bool won;
public static void FinishBattle(BattleResult result) {
sResult = result;
if (result.Won) {
Debug.Log("You won!");
} else {
Debug.Log("You lost!");
}
SceneManager.LoadScene("StoryScene");
}
public static BattleResult RetrieveResult() {
BattleResult result = sResult;
sResult = null;
return result;
}
public BattleResult(bool won) {
this.won = won;
}
public bool Won {get => this.won;}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d697460b6cb4ec9499c08ad6cb99dc32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,3 +1,4 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class BattleSetup {