Exemplo n.º 1
0
        public List <Point2D> GetWallOffPoints(List <Point2D> chokePoints)
        {
            var wallPoints = new List <Point2D>();

            foreach (var point in chokePoints)
            {
                if (BuildingService.AreaBuildable(point.X, point.Y, 1))
                {
                    wallPoints.Add(point);
                }
                else
                {
                    if (BuildingService.AreaBuildable(point.X, point.Y - 1, .1f))
                    {
                        wallPoints.Add(point);
                    }
                    if (BuildingService.AreaBuildable(point.X, point.Y + 1, .1f))
                    {
                        wallPoints.Add(point);
                    }

                    if (BuildingService.AreaBuildable(point.X - 1, point.Y, .1f))
                    {
                        wallPoints.Add(point);
                    }
                    if (BuildingService.AreaBuildable(point.X - 1, point.Y - 1, .1f))
                    {
                        wallPoints.Add(point);
                    }
                    if (BuildingService.AreaBuildable(point.X - 1, point.Y + 1, .1f))
                    {
                        wallPoints.Add(point);
                    }

                    if (BuildingService.AreaBuildable(point.X + 1, point.Y, .1f))
                    {
                        wallPoints.Add(point);
                    }
                    if (BuildingService.AreaBuildable(point.X + 1, point.Y - 1, .1f))
                    {
                        wallPoints.Add(point);
                    }
                    if (BuildingService.AreaBuildable(point.X + 1, point.Y + 1, .1f))
                    {
                        wallPoints.Add(point);
                    }
                }
            }

            return(wallPoints.Distinct().ToList());
        }
Exemplo n.º 2
0
        private BaseLocation GetNextBaseLocation()
        {
            var resourceCenters = ActiveUnitData.SelfUnits.Values.Where(u => u.UnitClassifications.Contains(UnitClassification.ResourceCenter));
            var openBases       = BaseData.BaseLocations.Where(b => !resourceCenters.Any(r => Vector2.DistanceSquared(r.Position, new Vector2(b.Location.X, b.Location.Y)) < 25));

            foreach (var openBase in openBases)
            {
                if (BuildingService.AreaBuildable(openBase.Location.X, openBase.Location.Y, 2) && !BuildingService.Blocked(openBase.Location.X, openBase.Location.Y, 2))
                {
                    return(openBase);
                }
            }
            return(null);
        }