Exemple #1
0
        public Point?GetClosestExploredLocation(Point origin)
        {
            int   distance        = int.MaxValue;
            Point?closestLocation = null;

            foreach (
                Point visibleLocation in
                VisibilityMap.GetSeenLocations().Where(
                    x => Race.MovementProfile.TerrainIsTraversable(GameInstance.Terrain[x])))
            {
                int currentDistance = origin.DistanceTo(visibleLocation);
                if (currentDistance >= distance)
                {
                    continue;
                }

                distance        = currentDistance;
                closestLocation = visibleLocation;
            }

            return(closestLocation);
        }
 private static IEnumerable <Point> GetWalkableSeenLocations(TerrainMap terrainMap, VisibilityMap visibilityMap, IMovementProfile movementProfile)
 {
     return(from location in visibilityMap.GetSeenLocations()
            where movementProfile.TerrainIsTraversable(terrainMap[location])
            select location);
 }