예제 #1
0
 private void TakeDamage(double amount, PlayerIdentifier shooter)
 {
     Debug.Log("Taking Damage");
     if (amount >= Health)
     {
         Health = 0;
         KillThisUnit(shooter);
     }
     else
     {
         Health -= amount;
         HealthChangeHandler handler = EventHealthChanged;
         if (oem.shouldTriggerEvent(handler))
         {
             Debug.Log("Triggering Health change event");
             handler(Health);
         }
     }
 }
예제 #2
0
 private void OnHealthChanged(int id, float value)
 {
     HealthChangeHandler?.Invoke(value, _stats[id].Max);
 }
예제 #3
0
 // add a subscriber to the event
 public void AddHealthSubscriber(HealthChangeHandler healthHandler)
 {
     _healthChangeEvent += healthHandler;
 }
예제 #4
0
 public void AddHealthChangeSubscriber(HealthChangeHandler healthChangeHandler)
 {
     _healthChangedEvent += healthChangeHandler;
     OnHealthChange();
 }