private IEnumerator LoseHP() { float hp = currPokemon.HitPoints; float maxHp = currPokemon.MaxHitPoints; while (damaged) { if (hp > targetHP) { hp -= 0.3f; yield return(null); } else if (hp <= targetHP) { hp = targetHP; currPokemon.HitPoints = targetHP; damaged = false; } if (currPokemon.CompareTag("Enemy")) { enemyHealthBar.fillAmount = hp / maxHp; if (hp <= maxHp / 2) { enemyHealthBar.color = yellowColor; } if (hp <= maxHp / 4) { enemyHealthBar.color = lowColor; } } else { playerHealthBar.fillAmount = hp / maxHp; hpText.text = Mathf.Round(hp) + "/" + maxHp; if (hp <= maxHp / 2) { playerHealthBar.color = yellowColor; } if (hp <= maxHp / 4) { playerHealthBar.color = lowColor; } } } }