Exemplo n.º 1
0
        public void BuildInsideWall(WallInCreator wallIn)
        {
            BoolGrid      pathable       = Bot.Main.MapAnalyzer.Pathable;
            ArrayBoolGrid walledPathable = new ArrayBoolGrid(pathable.Width(), pathable.Height());

            for (int x = 0; x < pathable.Width(); x++)
            {
                for (int y = 0; y < pathable.Height(); y++)
                {
                    if (!pathable[x, y])
                    {
                        walledPathable[x, y] = false;
                        continue;
                    }
                    bool blocked = false;
                    foreach (WallBuilding building in wallIn.Wall)
                    {
                        if (Math.Abs(building.Pos.X - x) <= building.Size.X / 2f &&
                            Math.Abs(building.Pos.Y - y) <= building.Size.Y / 2f)
                        {
                            blocked = true;
                            break;
                        }
                    }
                    walledPathable[x, y] = !blocked;
                }
            }
            LimitBuildArea = walledPathable.GetConnected(SC2Util.To2D(Bot.Main.MapAnalyzer.StartLocation));

            /*
             * DrawGrid(pathable, "Pathable");
             * DrawGrid(walledPathable, "WalledPathable");
             * DrawGrid(LimitBuildArea, "BuildArea");
             */
        }
Exemplo n.º 2
0
        public override void OnFrame(Bot bot)
        {
            if (NeedsScouting == null)
            {
                NeedsScouting = (ArrayBoolGrid)bot.MapAnalyzer.MainAndPocketArea.GetAnd(bot.MapAnalyzer.StartArea.Invert());
            }

            if (units.Count > 0 && SC2Util.DistanceSq(units[0].Unit.Pos, Target) <= 6 * 6)
            {
                Target = GetTarget(units[0].Unit.Pos);
                if (Target == null || bot.EnemyStrategyAnalyzer.Count(UnitTypes.REAPER) > 0)
                {
                    Done = true;
                    Clear();
                }
            }

            foreach (Agent agent in units)
            {
                agent.Order(Abilities.MOVE, Target);

                for (int dx = -6; dx <= 6; dx++)
                {
                    for (int dy = -6; dy <= 6; dy++)
                    {
                        if (dx * dx + dy * dy <= 6 * 6)
                        {
                            NeedsScouting[(int)agent.Unit.Pos.X + dx, (int)agent.Unit.Pos.Y + dy] = false;
                        }
                    }
                }
            }
        }