Ejemplo n.º 1
0
        private void UpdateWarpingInUnits()
        {
            WarpInInProgress = false;
            foreach (Agent agent in Bot.Main.Units())
            {
                if (agent.Unit.BuildProgress >= 0.99)
                {
                    continue;
                }
                if (agent.Unit.UnitType != UnitTypes.ZEALOT &&
                    agent.Unit.UnitType != UnitTypes.SENTRY &&
                    agent.Unit.UnitType != UnitTypes.STALKER &&
                    agent.Unit.UnitType != UnitTypes.ADEPT &&
                    agent.Unit.UnitType != UnitTypes.HIGH_TEMPLAR &&
                    agent.Unit.UnitType != UnitTypes.DARK_TEMPLAR)
                {
                    continue;
                }

                bool nearWarpPrism = false;
                foreach (Agent warpPrism in Units)
                {
                    if (agent.DistanceSq(warpPrism) <= 6 * 6)
                    {
                        nearWarpPrism = true;
                        break;
                    }
                }
                if (nearWarpPrism)
                {
                    WarpInInProgress = true;
                }
                if (!WarpInTags.Contains(agent.Unit.Tag))
                {
                    WarpPrismObjective removeObjective = null;
                    foreach (WarpPrismObjective objective in Objectives)
                    {
                        if (objective is WarpInObjective &&
                            ((WarpInObjective)objective).UnitType == agent.Unit.UnitType)
                        {
                            ((WarpInObjective)objective).Number--;
                            if (((WarpInObjective)objective).Number <= 0)
                            {
                                removeObjective = objective;
                            }
                            break;
                        }
                    }
                    if (removeObjective != null)
                    {
                        Objectives.Remove(removeObjective);
                    }
                    WarpInTags.Add(agent.Unit.Tag);
                }
            }
        }
Ejemplo n.º 2
0
        private void DeterminePickupTargets(Point2D armyLocation)
        {
            int count = 0;

            for (int i = Objectives.Count - 1; i >= 0; i--)
            {
                WarpPrismObjective objective = Objectives[i];
                if (objective is PickUpObjective)
                {
                    ulong tag = ((PickUpObjective)objective).UnitTag;
                    if (!Bot.Main.UnitManager.Agents.ContainsKey(tag))
                    {
                        Objectives.RemoveAt(i);
                        continue;
                    }
                    Agent agent = Bot.Main.UnitManager.Agents[tag];
                    if (!IsInDanger(agent))
                    {
                        Objectives.RemoveAt(i);
                        continue;
                    }
                    bool alreadyPickedUp = false;
                    foreach (Agent prism in Units)
                    {
                        foreach (PassengerUnit passenger in prism.Unit.Passengers)
                        {
                            if (passenger.Tag == tag)
                            {
                                alreadyPickedUp = true;
                            }
                        }
                        Bot.Main.DrawLine(prism, agent.Unit.Pos);
                    }
                    if (alreadyPickedUp)
                    {
                        Objectives.RemoveAt(i);
                        continue;
                    }
                    count++;
                }
            }
            foreach (Agent agent in Bot.Main.Units())
            {
                if (count >= 2)
                {
                    break;
                }
                if (!SaveUnitTypes.Contains(agent.Unit.UnitType))
                {
                    continue;
                }
                if (agent.Unit.IsFlying)
                {
                    continue;
                }
                if (agent.DistanceSq(armyLocation) >= 12 * 12)
                {
                    continue;
                }
                if (!IsInDanger(agent))
                {
                    continue;
                }
                Objectives.Add(new PickUpObjective()
                {
                    UnitTag = agent.Unit.Tag
                });
                foreach (Agent prism in Units)
                {
                    Bot.Main.DrawLine(prism, agent.Unit.Pos);
                }
                count++;
            }
        }