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); }
public Point2D FindHighGroundChokePoint(List <Vector2> path, float maxDistance = 30f) { if (path.Count > 0) { var startHeight = MapDataService.MapHeight(new Point2D { X = path[0].X, Y = path[0].Y }); var previousPoint = path[0]; foreach (var point in path) { if (startHeight > MapDataService.MapHeight(new Point2D { X = point.X, Y = point.Y })) { if (Vector2.DistanceSquared(path[0], point) > maxDistance * maxDistance) { return(null); } return(new Point2D { X = previousPoint.X, Y = previousPoint.Y }); } previousPoint = point; } } return(null); }