/// <summary> /// Moving to a room. /// </summary> /// <param name="d">The direction to move in.</param> /// <returns>The room just moved into.</returns> public Room moveInDirection(Direction d) { Room adjacentRoom = new Room(0, 0); if (GameState == Gstate.Menu) { // The user is in-menu. //Console.Out.WriteLine(""); } else if (GameState == Gstate.Game) { // The user is in-game. // Call map to see what room and chamber player is in. Room PlayerRoom = MyMap.getPlayerRoom(); // Call map to set adjacent rooms MyMap.setAdjacentRooms(MyCave.getConnectedRooms(PlayerRoom.getDecimalForm())); // Call cave to see what room is adjacent, in given direction. adjacentRoom = MyMap.getAdjacentRooms()[(int)d]; /*c.getConnectedExteralRoom(1, room);*/; if (adjacentRoom != null) { moveTo(adjacentRoom, d); //MyPlayer.setGold(MyPlayer.getGold() + MyMap.updateExploredAndReturnGold(adjacentRoom.getIntegerForm())); } else { return(new Room(0, 0)); } } return(adjacentRoom); }
public Room moveInDirection(Direction d) { Room adjacentRoom = new Room(0, 0); if (GameState == Gstate.Menu) { // The user is in-menu. //Console.Out.WriteLine(""); } else if (GameState == Gstate.Game) { // The user is in-game. // Call map to see what room and chamber player is in. Room PlayerRoom = MyMap.getPlayerRoom(); // Call map to set adjacent rooms MyMap.setAdjacentRooms(MyCave.loadCaveandRoom(PlayerRoom.getDecimalForm())); // Call cave to see what room is adjacent, in given direction. adjacentRoom = MyMap.getAdjacentRooms()[(int)d]; /*c.getConnectedExteralRoom(1, room);*/; if (adjacentRoom != null) { //adjacentRoom.LoadContent(theContentManager); // Call map to see if the room in given direction is hazardous. //roomType AdjacentRoomType = MyMap.getPlayerInRoomWith(MyRoom); //MyMap.GiveWarnings(chamber); // If is pitted: if (adjacentRoom.isRoomPitted()) { EncounterPit(); } // If it contains Wumpus: EncounterWumpus(); // Actually move to the room. MyMap.setPlayerRoom(adjacentRoom); MyMap.moves++; // Move Wumpus around MoveWumpus(false); // Returns player to center: ////MyPlayer.Position = new Vector2(RoomSize.Center.X, RoomSize.Center.Y); // OR, more realistically, the opposite side: MyPlayer.Position = getEntryLocationFrom((Direction)((((int)d + 1) % 4) + 1), MyPlayer.Position); } else { return(new Room(0, 0)); } } return(adjacentRoom); }