void Damage() { --health; onPlayerDamageEvent?.Raise(); GameplayScript.SetHpUI(health < 0 ? 0 : health); if (health <= 0) { OnPlayerDeath(); } else { coroutine = StartCoroutine(TemporaryImmunity()); } }
/// <summary> /// Damages the player. /// </summary> /// <param name="hp">[not needed] Hit points</param> public void Damage(float hp = 1) { //if it has temp immunity, do nothing if (isTempImmune) { return; } --health; //activates the event (sounds) and updates hud onPlayerDamageEvent?.Raise(); GameplayScript.SetHpUI(health < 0 ? 0 : health); if (health <= 0) { OnPlayerDeath(); } else { //if it has health left, call the temp immunity coroutine = StartCoroutine(TemporaryImmunity()); } }
void Start() { a_Verifier.Init(m_Rigidbody2D, chosenAbility); GameplayScript.SetHpUI(health); }
/// <summary> /// Adds player a hit point. /// </summary> public void AddHP() { ++health; GameplayScript.SetHpUI(health); }