Пример #1
0
 void OnDisable()
 {
     UnitDeathEvent.UnregisterListener(OnEnemyUnitDeath);
     EnemyAttackEvent.UnregisterListener(OnEnemyUnitAttack);
     LeftMouseSelectEvent.UnregisterListener(OnLeftMouseSelected);
     RightMouseSelectEvent.UnregisterListener(OnRightMouseClick);
     PlayerAttackEvent.UnregisterListener(OnAttacked);
 }
Пример #2
0
    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);
    }
Пример #3
0
    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;
            }
        }
    }
Пример #4
0
 public void HandleMissive(EnemyAttackEvent missive)
 {
     enemyAttackSound(missive.position);
 }