using System.Collections; using System.Collections.Generic; using UnityEngine; public class VictoryDefeat : MonoBehaviour { private bool _wavesEnd = false; public Canvas victoryCanvas; public Canvas defeatCanvas; public const float positionLoseLimit = -10.0f; void Start() { victoryCanvas.gameObject.SetActive(false); defeatCanvas.gameObject.SetActive(false); } void Update() { List opponentsList = LevelManager.Instance.GetAll(x => x is Opponent); //I believe that we win if the waves are finished and there are no more monsters (to be modified in the case that's not it) if(_wavesEnd && opponentsList.Count == 0) { victoryCanvas.gameObject.SetActive(true); //win ! } //I estimate that we lose if one of the enemies arrives behind our line of defense (to be modified in the case it's not that) foreach (Opponent opponent in opponentsList) { if (opponent.transform.position.x < positionLoseLimit) { defeatCanvas.gameObject.SetActive(true); //lose :( } } } }