public void attack(HealthComponent healthComponent) { AnimateAttack(); healthComponent.GetHit(damage); attacking = true; UIManager.setInfoChanged(true); }
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); }