/// <summary> /// Reduces health of the paddle by the given value /// </summary> /// <param name="health"> The health value to reduce </param> public void ReduceHealth(int health) { // subrtracts the given health from current health CurrentHealth -= health; // Ensures that the value is between 0 and max health CurrentHealth = Mathf.Clamp(CurrentHealth, 0, MaxHealth); OnPaddleHealthUpdated?.Invoke(); if (CurrentHealth <= 0) { OnPaddleHealthZero?.Invoke(); } }
/// <summary> /// Drains the health of the paddle empty /// </summary> public void DrainHealth() { CurrentHealth = 0; OnPaddleHealthUpdated?.Invoke(); OnPaddleHealthZero?.Invoke(); }
/// <summary> /// Refills the current health back to full /// </summary> public void RefillHealth() { CurrentHealth = MaxHealth; OnPaddleHealthUpdated?.Invoke(); }