void Check() { state = (int)State.wait; float totOpponentHp = 0; foreach (PartyPokemon p in Party.opponentParty) //see if opponent has any pokemon with hp left { totOpponentHp += p.CurrentHp; if (p.CurrentHp > 0) //if it dose set active pokemon to it { opponentPokemon = p; } } if (totOpponentHp <= 0) //if not end fight { waitTime = 1; eventText.text = "Player won"; nextState = (int)State.end; } float totPlayerHp = 0; foreach (PartyPokemon p in Party.playerParty) { totPlayerHp += p.CurrentHp; if (p.CurrentHp > 0) { playerPokemon = p; } } if (totPlayerHp <= 0) { waitTime = 1; eventText.text = "Opponent won"; nextState = (int)State.end; } updateUI.UIUpdate(playerPokemon, opponentPokemon); //update UI here because it feels logical }