void OnDisable() { UnitDeathEvent.UnregisterListener(OnEnemyUnitDeath); EnemyAttackEvent.UnregisterListener(OnEnemyUnitAttack); LeftMouseSelectEvent.UnregisterListener(OnLeftMouseSelected); RightMouseSelectEvent.UnregisterListener(OnRightMouseClick); PlayerAttackEvent.UnregisterListener(OnAttacked); }
private void OnEnemyUnitAttack(EnemyAttackEvent unitAttack) { float actualDamageTaken = unitAttack.UnitStats.Damage; actualDamageTaken -= stats.Armor; stats.CurrentHealth -= actualDamageTaken; Debug.Log(unitAttack.UnitAttacked.name + " took " + actualDamageTaken + " damage from " + unitAttack.UnitAttacker.name); Debug.Log(stats.CurrentHealth); }
public void DoDamage(float damage) { // TODO: Make this independent on Player attacking the object first. if (stats != null) { if (Time.time - timeSinceAttack > 1.5) { EnemyAttackEvent enemyAttack = new EnemyAttackEvent(); enemyAttack.UnitAttacker = stats.gameObject; enemyAttack.UnitAttacked = player.gameObject; enemyAttack.UnitStats = stats; enemyAttack.FireEvent(); timeSinceAttack = Time.time; } } }
public void HandleMissive(EnemyAttackEvent missive) { enemyAttackSound(missive.position); }