Player Damage
Last updated
Last updated
PlayerDamage
class is responsible for managing the damage taken by the player. It tracks the amount of damage received, enforces damage thresholds, and coordinates with other components to reflect the player's damaged state both visually and functionally.
Properties
private PlayerWorker playerWorker
: References the PlayerWorker
associated with PlayerDamage
private float damageCounter
: Represents the cumulative damage received.private float damageLimit
: Represents the threshold of damage the player can receive before triggering a response.
Constructor
public PlayerDamage(PlayerWorker playerWorker)
: Initializes a new instance of the PlayerDamage
class, assigning the PlayerWorker
.
Methods
public void OnPlayerDamage()
: Invoked when the player receives damage. It checks the damage counter against the limit and, if exceeded, plays the hit animation, disables the player, and starts a coroutine to reset the player's state after a delay.
public IEnumerator ResetState()
: A coroutine that waits for a specified duration before re-enabling the player and turning off the hit animation, effectively resetting the player's state post-damage.