예제 #1
0
        private bool IsFlatChoke(Point2D chokePoint)
        {
            // check area of map with radius of 10 around this, if percentage that is walkable and the same height is below certain amount it's a choke point
            var notChokeCount = 0;
            var startHeight   = MapDataService.MapHeight(chokePoint);

            for (var x = -5; x < 10; x++)
            {
                for (var y = -5; y < 10; y++)
                {
                    if (MapDataService.MapHeight(x + (int)chokePoint.X, y + (int)chokePoint.Y) == startHeight && MapDataService.PathWalkable(x + (int)chokePoint.X, y + (int)chokePoint.Y))
                    {
                        if (!TouchingLowerPoint(x + (int)chokePoint.X, y + (int)chokePoint.Y, startHeight) || !TouchingUnwalkablePoint(x + (int)chokePoint.X, y + (int)chokePoint.Y, startHeight))
                        {
                            notChokeCount++;
                            if (notChokeCount > 50)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(true);
        }
예제 #2
0
        public List <Point2D> GetTargetArea(Point2D point, int size = 25)
        {
            var points = new List <Point2D>();

            var startHeight = MapDataService.MapHeight(point);

            for (var x = -size; x < size; x++)
            {
                for (var y = -size; y < size; y++)
                {
                    if (x + point.X > 0 && x + point.X < MapDataService.MapData.MapWidth && y + point.Y > 0 && y + point.Y < MapDataService.MapData.MapHeight)
                    {
                        if (MapDataService.MapHeight(x + (int)point.X, y + (int)point.Y) == startHeight && MapDataService.PathWalkable(x + (int)point.X, y + (int)point.Y))
                        {
                            points.Add(new Point2D {
                                X = x + (int)point.X, Y = y + (int)point.Y
                            });
                        }
                    }
                }
            }

            return(points);
        }