Forgotten Empires
  • Welcome!
  • Getting Started
  • Why On Chain Game?
  • Why MINA?
  • Architecture of Forgotten Empires
  • Prerequisites
  • Building Forgotten Empires to Unity
  • Game
    • Unity
      • Component
        • Type
          • Animation Type
          • Music Type
          • State Type
          • VFX Type
      • Entity
        • Element
          • Component
            • Enemy
              • Enemy Worker
                • Enemy Animation
                • Enemy Behaviour
                  • Component
                    • Enemy Attack Behaviour
                    • Enemy Attack Stance Behaviour
                    • Enemy Idle Behaviour
            • NPC
              • Citizen
              • Merchant
                • Merchant Interaction
                • Merchant Trade
                • Merchant Trigger
                • Merchant UI
                • Merchant Update
            • Player
              • Player Animation
              • Player Attack
              • Player Camera
              • Player Damage
              • Player Economy
              • Player Fixed Update
              • Player Input
                • Player Attack Input
                • Player Movement Input
                • Player Rotation Input
              • Player Interaction
              • Unity Late Update
              • Player Inventory
                • Player Inventory Slot
              • Player Movement
              • Player Quest
              • Player Rotation
                • Player Attack Rotation
                • Player Movement Rotation
              • Player Start
              • Player State
              • Player Stats
                • Player On Chain Stats
              • Player Trails
              • Player Update
              • Player VFX
          • Element Worker
            • Element Effect
            • Element Event
            • Element Stats
            • Element Update
        • Item
          • Potion
          • Shield
          • Sword
        • Kingdom
      • Manager
        • Client Manager
          • Client Manager Worker
            • Client Login Worker
            • Client Music Manager
            • Client Start Worker
            • Client UI Worker
            • Client Update Worker
        • Server Manager
          • Server Manager Worker
            • Server Day Night Worker
            • Server Enemy Worker
            • Server Kingdom Worker
            • Server Object Pool Worker
            • Server Player Worker
            • Server Start Worker
            • Server Update Worker
    • o1js
      • Player
      • Item
      • Character
    • o1js Tests
Powered by GitBook
On this page
  1. Game
  2. Unity
  3. Entity
  4. Element
  5. Component
  6. Player

Player Damage

Last updated 1 year ago

CtrlK

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.