IEnumerator EnemyTurn() { dialogue.text = $"Wild {enemyPokemon.pokemonName.ToUpper()} used Tackle!"; yield return(new WaitForSeconds(2f)); enemyAnim.SetTrigger("Attack"); playerAnim.SetTrigger("Hurt"); playerHudAnim.SetTrigger("PlayerHurt"); bool isDead = playerPokemon.TakeDmg(enemyPokemon.dmg); playerHud.SetHp(playerPokemon.currentHp); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator PlayerAttack() { dialogue.text = $"{playerPokemon.pokemonName.ToUpper()} used Tackle!"; yield return(new WaitForSeconds(3f)); playerAnim.SetTrigger("Attack"); enemyAnim.SetTrigger("Hurt"); playerHudAnim.SetTrigger("EnemyHurt"); bool isDead = enemyPokemon.TakeDmg(playerPokemon.dmg); enemyHud.SetHp(enemyPokemon.currentHp); if (isDead) { state = BattleState.WIN; EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }