Beispiel #1
0
        /// <summary>
        /// a function to check if there is an available building to research an upgrade
        /// </summary>
        /// <param name="upgradeId">desired upgrade to be researched</param>
        /// <returns>true if an idle building is waiting, false otherwise</returns>
        public static bool TrainingBuildingAvailable(int upgradeId)
        {
            HashSet <uint> hs = UpgradeHelper.GetUpgradeBuildingTypes(upgradeId);

            if (VBot.Bot.StateManager.GetAvailableAgent(hs) != null)
            {
                return(true);
            }
            return(false);
        }
Beispiel #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();
         }
     }
 }