示例#1
0
 /// <summary>
 ///     Checks if there is a free unit to move to morph into a the desired unit
 /// </summary>
 /// <param name="unitType">the unit type of the desired unit</param>
 /// <returns>true if there is a free unit, false otherwise</returns>
 public static bool PreMorphUnitAvailable(uint unitType)
 {
     if (MorphHelper.MorpSteps.ContainsKey(unitType))
     {
         if (null != GetAvailableAgent(MorphHelper.GetPreMorphType(unitType)))
         {
             return(true);
         }
         return(false);
     }
     else
     {
         Logger.Info("Calling Controller.PreMorphUnitAvailable() on a unit that isnt in morph list. Unit: {0}, Type: {1}",
                     VBot.Bot.Data.Units[(int)unitType], unitType);
         return(false);
     }
 }
示例#2
0
 // Methods
 /// <summary>
 /// checks if it is possible to build/research unit/upgrade, then gets an agent and orders it to complete the task.
 /// </summary>
 public override void OnFrame()
 {
     if (UnitType != 0) // make a unit
     {
         if (Controller.CanMakeUnit(UnitType) && FromAgent == null)
         {
             // set the from type and execute the task
             if (MorphHelper.MorpSteps.ContainsKey(UnitType))
             {
                 FromAgent = Controller.GetAvailableAgent(MorphHelper.GetPreMorphType(UnitType));
                 FromAgent.Order(Units.GetAbilityId(UnitType)); // acts as execute()
                 Clear();                                       // only dismissed as it is morph type and eggs are useless and don't need to be busy
             }
             else if (TrainHelper.TrainSteps.ContainsKey(UnitType))
             {
                 FromAgent      = Controller.GetAvailableAgent(TrainHelper.GetTrainingBuildingTypes(UnitType));
                 FromAgent.Busy = true;
                 FromAgent.Order(Units.GetAbilityId(UnitType)); // acts as execute()
             }
             else
             {
                 FromAgent      = Controller.GetAvailableAgent(Units.Workers);
                 FromAgent.Busy = true;
                 Controller.BuildStructure(FromAgent, UnitType); // acts as Execute()
             }
         }
         else if (FromAgent != null)
         {
             if (FromAgent.Unit.Orders.Count == 0)
             {
                 // agent is idle. clear it
                 Clear();
             }
         }
         else
         {
             Clear();
         }
     }
     else
     {
         if (Controller.CanMakeUpgrade(UpgradeType) && FromAgent == null)
         {
             FromAgent      = Controller.GetAvailableAgent(UpgradeHelper.GetUpgradeBuildingTypes(UpgradeType));
             FromAgent.Busy = true;
             FromAgent.Order(Upgrades.GetAbilityId(UpgradeType));
         }
         else if (FromAgent != null)
         {
             if (FromAgent.Unit.Orders.Count == 0)
             {
                 FromAgent.Busy = false;
                 Clear();
             }
         }
         else
         {
             Clear();
         }
     }
 }