public static void FindPath(IAsciiMap map, IAsciiField currentField, PathDirection currentDirection)
        {
            map.AddPathCharacter(currentField);
            var         directionToMoveNext = ScanArea(map, currentField, currentDirection);
            IAsciiField nextField           = map.GetFieldInDirection(directionToMoveNext, currentField);

            if (IsAsciiEndCharacter(nextField.Character))
            {
                map.AddPathCharacter(nextField);
            }
            else
            {
                FindPath(map, nextField, directionToMoveNext);
            }
        }
Ejemplo n.º 2
0
        private static IAsciiMap LoadAsciiMap(MapSelector mapSelector)
        {
            IAsciiMap map = null;

            try
            {
                map = MapLoader.LoadAsciiMap(mapSelector);
            }
            catch (Exception e)
            {
                log.Error("Error loading ascii map!", e);
                Environment.Exit(1);
            }

            return(map);
        }
        public static PathDirection ScanArea(IAsciiMap map, IAsciiField currentField, PathDirection currentPathDirection)
        {
            if (currentPathDirection != PathDirection.Unknown &&
                IsDirectionPreserved(map, currentField, currentPathDirection))
            {
                return(currentPathDirection);
            }

            foreach (PathDirection direction in Enum.GetValues(typeof(PathDirection)))
            {
                if (IsDirectionValid(map, currentField, direction))
                {
                    return(direction);
                }
            }

            return(PathDirection.Unknown);
        }