Example #1
0
 public void ProcessAttack()
 {
     if (unitControl.IsDead() || unitControl.IsAttacking() || unitControl.IsWaiting())
     {
         return;
     }
     if (cooldown > 0)
     {
         cooldown -= Time.deltaTime;
     }
     if (!unitControl.GetCurrentEnemy() || unitControl.GetCurrentEnemy().IsDead())
     {
         unitControl.FindNewEnemy(true);
     }
     else
     {
         float distance = (unitControl.GetCurrentEnemy().transform.position - transform.position).sqrMagnitude;
         if (attackRange > distance)
         {
             if (cooldown < 0)
             {
                 Attack();
             }
         }
     }
 }