public void TakeDamage(int damage) { EnemyDamageEvent enemyDamageEventInfo = new EnemyDamageEvent(); enemyDamageEventInfo.Description = "Actor " + gameObject.name + " has taken damage."; enemyDamageEventInfo.enemy_go = gameObject; enemyDamageEventInfo.FireEvent(); //Do take damage animation stats.health -= damage; if (stats.health <= 0) { EnemyDie(); } }
void OnEnemyDamaged(EnemyDamageEvent enemyDamage) { Debug.Log("I hear " + enemyDamage.enemy_go.name + " has taken damage - Report from the DamageListener"); }
// Use this for initialization void Start() { PlayerDamageEvent.RegisterListener(OnPlayerDamaged); EnemyDamageEvent.RegisterListener(OnEnemyDamaged); TileDamageEvent.RegisterListener(OnTileDamaged); }
void OnDestroy() { PlayerDamageEvent.UnregisterListener(OnPlayerDamaged); EnemyDamageEvent.UnregisterListener(OnEnemyDamaged); TileDamageEvent.UnregisterListener(OnTileDamaged); }