private Navigaion GetRoomProperties(int roomId) { var roomProperties = new Navigaion { NorthRoom = _mazeIntegration.GetRoom(roomId, 'N'), SouthRoom = _mazeIntegration.GetRoom(roomId, 'S'), WestRoom = _mazeIntegration.GetRoom(roomId, 'W'), EastRoom = _mazeIntegration.GetRoom(roomId, 'E') }; return(roomProperties); }
public void Move(char direction) { var newRoomId = _mazeIntegration.GetRoom(_loadPlayer.GetPlayerInstance().CurrentRoom.Id, direction); if (newRoomId.HasValue) { _loadMaze.GetMazeMapInstance().mazeRooms.Where(r => r.Id == newRoomId).FirstOrDefault().IsVisited = true; _loadPlayer.GetPlayerInstance().CurrentRoom = _loadMaze.GetMazeMapInstance().mazeRooms.Where(r => r.Id == newRoomId).FirstOrDefault(); _loadPlayer.GetPlayerInstance().StepsMade++; CheckCurrentRoom(); CheckSelf(); } else { Console.WriteLine(Constants.PlayerConstants.InvalidDirection); } }
/// <summary> /// In InProgress State : the player continue pressing the arrow until he wins or lose. /// </summary> /// <param name="key"></param> private void InProgressState(ConsoleKey key) { if (_input.IsArrow(key)) { char direction = ' '; if (_input.IsUpArrow(key)) { direction = 'N'; } if (_input.IsDownArrow(key)) { direction = 'S'; } if (_input.IsRightArrow(key)) { direction = 'E'; } if (_input.IsLeftArrow(key)) { direction = 'W'; } //-------------get next room----------------------------------------- int?nextRoom = _mazeIntegration.GetRoom(_play.CurrentRoom, direction); if (nextRoom == null) { _render.Message(MessageTypes.outsideMaze); } else { _input.clearInput(); _play.CurrentRoom = nextRoom.Value; GetRoomInfo(_play.CurrentRoom); } } else { //--------reder message please use the arrows ------------ _render.Message(MessageTypes.Instruction); } }