public void TakeDamage(int damage) { Debug.Log(this.name + " got hit for " + damage); hP -= damage; // Trigger Attacked Event callback EventCallbacks.HPChangedEventInfo hpcei = new EventCallbacks.HPChangedEventInfo(); hpcei.EventDescription = "Unit " + gameObject.name + " Has taken " + damage + " damage"; hpcei.UnitGO = gameObject; hpcei.FireEvent(); // check for death if (hP <= 0) { CharacterDies(); } }
public void RecoverHitPoints(int hitPoints) { Debug.Log(this.name + " got healed for " + hitPoints); hP = Mathf.Clamp(hP += hitPoints, 0, maxHP); // Trigger Attacked Event callback - // TODO... Alter these events, split 'TakeDamage' into separate 'GetAttacked' and 'HealthChanged' events (currently only 'HealthChanged' would be used) EventCallbacks.HPChangedEventInfo hpcei = new EventCallbacks.HPChangedEventInfo(); hpcei.EventDescription = "Unit " + gameObject.name + " Has recovered " + hP + " health"; hpcei.UnitGO = gameObject; hpcei.FireEvent(); // check for death if (hP <= 0) { CharacterDies(); } }