Ejemplo n.º 1
0
        public Maze.MazeProperties NavigationStart(Player player)
        {
            var entranceRoomId = -1;

            Console.WriteLine("Starting maze navigation.");
            Console.WriteLine("Parsing maze metadata..");
            Console.WriteLine("Getting entrance room...");
            try
            {
                entranceRoomId = _mazeIntegration.GetEntranceRoom();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error, No room entrence was found!");
                Console.WriteLine(e.StackTrace.ToString());
                //TODO log e using NLog or whatever
                Console.ReadLine();
                Environment.Exit(0);
            }


            Console.WriteLine("Initialize room entrence....");

            return(EmulateMaze(player, entranceRoomId));
        }
Ejemplo n.º 2
0
        private void NewGameState(ConsoleKey key)
        {
            _input.clearInput();
            var mazeSize = _input.ToNumber(key);

            if (mazeSize == null)
            {
                _render.Message(MessageTypes.InvalidInput);
            }
            else if (mazeSize <= 1)
            {
                _render.Message(MessageTypes.InvalidInput);
            }
            else
            {
                //---------Build the maze and get the entrance room -----------
                _play          = new Play();
                _play.MazeSize = mazeSize.Value;
                _mazeIntegration.BuildMaze(_play.MazeSize);
                _play.CurrentRoom = _mazeIntegration.GetEntranceRoom();
                string desc = _mazeIntegration.GetDescription(_play.CurrentRoom);

                //---------Render the maze and the moves -----------
                _play.VisitedRooms.Add(new Room()
                {
                    Description = desc,
                    HasTrap     = false,
                    HasTreasure = false,
                    RoomId      = _play.CurrentRoom
                });
                _render.EntranceRoom(_play.CurrentRoom);
                _render.Message(MessageTypes.Instruction);
                _render.Moves(_play);
                _currentState = State.InProgress;
            }
        }