Пример #1
0
 public WeaponController AttackFuntcion(WeaponController[] _weapons, HealthController _health, float _distance, float _time)
 {
     if (Time.time > _time)
     {
         List <WeaponController> inReach = new List <WeaponController> ();
         for (int i = 0; i < _weapons.Length; i++)
         {
             if (_weapons[i].GetReach() > _distance)
             {
                 inReach.Add(_weapons [i]);
             }
         }
         List <WeaponController> canAfford = new List <WeaponController> ();
         foreach (WeaponController WC in inReach)
         {
             if (WC.GetManaCost() < _health.GetCurrentMana())
             {
                 canAfford.Add(WC);
             }
         }
         WeaponController selectedAttack  = null;
         float            highestCooldown = 0;
         foreach (WeaponController WC in canAfford)
         {
             if (WC.GetAttackCoolDown() > highestCooldown)
             {
                 selectedAttack = WC;
             }
         }
         return(selectedAttack);
     }
     return(null);
 }