public void SetAndGetRoomSides() { var room1 = new Room(1); var room2 = new Room(2); room1.SetSide(Room.directions.north, new Wall()); room1.SetSide(Room.directions.east, new Wall()); room1.SetSide(Room.directions.south, new Door(room1, room2)); room1.SetSide(Room.directions.west, new Wall()); Assert.AreEqual(typeof(Wall), room1.GetSide(Room.directions.north).GetType()); Assert.AreEqual(typeof(Wall), room1.GetSide(Room.directions.east).GetType()); Assert.AreEqual(typeof(Door), room1.GetSide(Room.directions.south).GetType()); Assert.AreEqual(typeof(Wall), room1.GetSide(Room.directions.west).GetType()); room2.SetSide(Room.directions.north, new Door(room1, room2)); room2.SetSide(Room.directions.east, new Door(room1, room2)); room2.SetSide(Room.directions.south, new Wall()); room2.SetSide(Room.directions.west, new Door(room1, room2)); Assert.AreEqual(typeof(Door), room2.GetSide(Room.directions.north).GetType()); Assert.AreEqual(typeof(Door), room2.GetSide(Room.directions.east).GetType()); Assert.AreEqual(typeof(Wall), room2.GetSide(Room.directions.south).GetType()); Assert.AreEqual(typeof(Door), room2.GetSide(Room.directions.west).GetType()); }
public Level(Maze maze, Room startingRoom, Room finishingRoom, Func<Level> next) { this.maze = maze; this.startingRoom = startingRoom; this.finishingRoom = finishingRoom; this.next = next; }
public void DoorIsOpenByDefault() { var room1 = new Room(1); var room2 = new Room(2); var door = new Door(room1, room2); Assert.IsTrue(door.isOpen()); }
public void SetAndGetRoomNumber() { var room1 = new Room(1); Assert.AreEqual(1, room1.GetRoomNumber()); var room2 = new Room(2); Assert.AreEqual(2, room2.GetRoomNumber()); }
private void Draw(Room room) { DrawCenter(); DrawNorthWall(room); DrawEastWall(room); DrawSouthWall(room); DrawWestWall(room); }
public void PlayerCanEnterDoor() { var room1 = new Room(1); var room2 = new Room(2); var door = new Door(room1, room2); var player = new Player(room1, room2); Assert.AreEqual(room2, door.Enter(player)); }
private void Draw(Room room) { StopAllCurrentAnimation(); DrawCenter(); DrawNorthWall(room); DrawEastWall(room); DrawSouthWall(room); DrawWestWall(room); }
public void PlayerHasFinished_When_CurrentRoomEqualsFinishRoom() { var room1 = new Room(1); var room2 = new Room(2); var player1 = new Player(room1, room2); Assert.IsFalse(player1.hasFinished()); var player2 = new Player(room1, room1); Assert.IsTrue(player2.hasFinished()); }
public void DoorCanBeClosedAndOpened() { var room1 = new Room(1); var room2 = new Room(2); var door = new Door(room1, room2); Assert.IsTrue(door.isOpen()); door.CloseDoor(); Assert.IsFalse(door.isOpen()); door.OpenDoor(); Assert.IsTrue(door.isOpen()); }
public void CannotEnterAWall() { var room1 = new Room(1); var room2 = new Room(2); var player = new Player(room1, room2); var wall = new Wall(); try { wall.Enter(player); throw new Exception("TEST FAILED"); } catch (Exception e) { Assert.AreEqual("You just ran into a wall. Have you been drinking?", e.Message); } }
public void Draw(Room room) { Console.Clear(); Console.SetCursorPosition(0, Console.CursorTop); bool hasNorthDoor = room.GetSide(Room.directions.north).GetType() == typeof(Door); string northSegment = (hasNorthDoor ? "| |" : ". . . . . . . . ."); bool hasEastDoor = room.GetSide(Room.directions.east).GetType() == typeof(Door); string eastSegment1 = (hasEastDoor ? "--" : "."); string eastSegment2 = (hasEastDoor ? " " : "."); bool hasSouthDoor = room.GetSide(Room.directions.south).GetType() == typeof(Door); string southSegment = (hasSouthDoor ? "| |" : ". . . . . . . . ."); bool hasWestDoor = room.GetSide(Room.directions.west).GetType() == typeof(Door); string westSegment1 = (hasWestDoor ? "--" : " ."); string westSegment2 = (hasWestDoor ? " " : " ."); Console.WriteLine( " . . . . . . . . . . . " + northSegment + " . . . . . . . . . . . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ..... ."); Console.WriteLine(westSegment1 + " | | " + eastSegment1); Console.WriteLine(westSegment2 + " ..... " + eastSegment2); Console.WriteLine(westSegment2 + " . " + eastSegment2); Console.WriteLine(westSegment2 + " . " + eastSegment2); Console.WriteLine(westSegment2 + " . . . " + eastSegment2); Console.WriteLine(westSegment2 + " . . . . . " + eastSegment2); Console.WriteLine(westSegment2 + " . " + eastSegment2); Console.WriteLine(westSegment2 + " . . " + eastSegment2); Console.WriteLine(westSegment2 + " . . " + eastSegment2); Console.WriteLine(westSegment1 + " . . " + eastSegment1); Console.WriteLine( " . ... ... ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . ."); Console.WriteLine( " . . . . . . . . . . . " + southSegment + " . . . . . . . . . . . ."); }
public Door(Room room1, Room room2) { this.room1 = room1; this.room2 = room2; OpenDoor(); }
public Door MakeDoor(Room room1, Room room2) { return new Door(room1, room2); }
private void DrawNorthWall(Room room) { bool hasNorthDoor = isDoor(room.GetSide(Room.directions.north)); this.NorthWall.Image = (hasNorthDoor ? global::DogMaze.GUI.Properties.Resources.MazeBackGroundTopDoor : global::DogMaze.GUI.Properties.Resources.MazeBackGroundTopNoDoor); }
private void DrawSouthWall(Room room) { bool hasSouthDoor = isDoor(room.GetSide(Room.directions.south)); this.SouthWall.Image = (hasSouthDoor ? global::DogMaze.GUI.Properties.Resources.MazeBackGroundBottomDoor : global::DogMaze.GUI.Properties.Resources.MazeBackGroundBottomNoDoor); }
private void DrawEastWall(Room room) { bool hasEastDoor = isDoor(room.GetSide(Room.directions.east)); this.EastWall.Image = (hasEastDoor ? global::DogMaze.GUI.Properties.Resources.MazeBackGroundRightDoor : global::DogMaze.GUI.Properties.Resources.MazeBackGroundRightNoDoor); }
public void Transition(Room.directions direction) { Console.Clear(); Console.SetCursorPosition(0, Console.CursorTop); bool moveNorth = direction == Room.directions.north; bool moveEast = direction == Room.directions.east; bool moveSouth = direction == Room.directions.south; bool moveWest = direction == Room.directions.west; if (moveSouth) { Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" ..... "); Console.WriteLine(" | | "); Console.WriteLine(" ..... "); Console.WriteLine(" . "); Console.WriteLine(" . "); Console.WriteLine(" . . . "); Console.WriteLine(" . . . . . "); Console.WriteLine(" . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" ... ... "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); } else if (moveWest) { Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" ..... "); Console.WriteLine(" | | "); Console.WriteLine(" ..... "); Console.WriteLine(" . "); Console.WriteLine(" . "); Console.WriteLine(" . . . "); Console.WriteLine(" . . . . . "); Console.WriteLine(" . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" ... ... "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); } else if (moveNorth) { Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" ..... "); Console.WriteLine(" | | "); Console.WriteLine(" ..... "); Console.WriteLine(" . "); Console.WriteLine(" . "); Console.WriteLine(" . . . "); Console.WriteLine(" . . . . . "); Console.WriteLine(" . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" ... ... "); Console.WriteLine(" "); Console.WriteLine(" "); } else if (moveEast) { Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" ..... "); Console.WriteLine(" | | "); Console.WriteLine(" ..... "); Console.WriteLine(" . "); Console.WriteLine(" . "); Console.WriteLine(" . . . "); Console.WriteLine(" . . . . . "); Console.WriteLine(" . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" . . "); Console.WriteLine(" ... ... "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); } System.Threading.Thread.Sleep(100); }
public void Move(Room.directions direction) { currentRoom = currentRoom.GetSide(direction).Enter(this); }
public void AddRoom(Room room) { rooms.Add(room); }
public Player(Room startRoom, Room finishRoom) { this.currentRoom = startRoom; this.finishRoom = finishRoom; }