示例#1
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;
            }
        }