Example #1
0
        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());
        }
Example #2
0
 public Level(Maze maze, Room startingRoom, Room finishingRoom, Func<Level> next)
 {
     this.maze = maze;
     this.startingRoom = startingRoom;
     this.finishingRoom = finishingRoom;
     this.next = next;
 }
Example #3
0
        public void DoorIsOpenByDefault()
        {
            var room1 = new Room(1);
            var room2 = new Room(2);
            var door = new Door(room1, room2);

            Assert.IsTrue(door.isOpen());
        }
Example #4
0
        public void SetAndGetRoomNumber()
        {
            var room1 = new Room(1);
            Assert.AreEqual(1, room1.GetRoomNumber());

            var room2 = new Room(2);
            Assert.AreEqual(2, room2.GetRoomNumber());
        }
Example #5
0
 private void Draw(Room room)
 {
     DrawCenter();
     DrawNorthWall(room);
     DrawEastWall(room);
     DrawSouthWall(room);
     DrawWestWall(room);
 }
Example #6
0
        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));
        }
Example #7
0
 private void Draw(Room room)
 {
     StopAllCurrentAnimation();
     DrawCenter();
     DrawNorthWall(room);
     DrawEastWall(room);
     DrawSouthWall(room);
     DrawWestWall(room);
 }
Example #8
0
        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());
        }
Example #9
0
        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());
        }
Example #10
0
        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);
            }
        }
Example #11
0
        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 + " . . . . . . . . . . . .");
        }
Example #12
0
 public Door(Room room1, Room room2)
 {
     this.room1 = room1;
     this.room2 = room2;
     OpenDoor();
 }
Example #13
0
 public Door MakeDoor(Room room1, Room room2)
 {
     return new Door(room1, room2);
 }
Example #14
0
 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);
 }
Example #15
0
 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);
 }
Example #16
0
 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);
 }
Example #17
0
        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);
        }
Example #18
0
 public void Move(Room.directions direction)
 {
     currentRoom = currentRoom.GetSide(direction).Enter(this);
 }
Example #19
0
 public void AddRoom(Room room)
 {
     rooms.Add(room);
 }
Example #20
0
 public Player(Room startRoom, Room finishRoom)
 {
     this.currentRoom = startRoom;
     this.finishRoom = finishRoom;
 }