コード例 #1
0
 public void attack(HealthComponent healthComponent)
 {
     AnimateAttack();
     healthComponent.GetHit(damage);
     attacking = true;
     UIManager.setInfoChanged(true);
 }
コード例 #2
0
        public bool FindAndAttackEnemyInRange(Vector2 towerPosition, float attackRange, int damage)
        {
            foreach (EnemyMain enemy in enemiesManager.ActiveEnemies)
            {
                if (Vector2.Distance(enemy.transform.position, towerPosition) <= attackRange)
                {
                    HealthComponent enemyHealthComponent = enemy.GetComponent <HealthComponent>();
                    if (enemyHealthComponent != null)
                    {
                        enemyHealthComponent.GetHit(damage);
                        return(true);
                    }
                }
            }

            return(false);
        }