Пример #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());
        }
Пример #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;
 }
Пример #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());
        }
Пример #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());
        }
Пример #5
0
 private void Draw(Room room)
 {
     DrawCenter();
     DrawNorthWall(room);
     DrawEastWall(room);
     DrawSouthWall(room);
     DrawWestWall(room);
 }
Пример #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));
        }
Пример #7
0
 private void Draw(Room room)
 {
     StopAllCurrentAnimation();
     DrawCenter();
     DrawNorthWall(room);
     DrawEastWall(room);
     DrawSouthWall(room);
     DrawWestWall(room);
 }
Пример #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());
        }
Пример #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());
        }
Пример #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);
            }
        }
Пример #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 + " . . . . . . . . . . . .");
        }
Пример #12
0
 public Door(Room room1, Room room2)
 {
     this.room1 = room1;
     this.room2 = room2;
     OpenDoor();
 }
Пример #13
0
 public Door MakeDoor(Room room1, Room room2)
 {
     return new Door(room1, room2);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
        }
Пример #18
0
 public void Move(Room.directions direction)
 {
     currentRoom = currentRoom.GetSide(direction).Enter(this);
 }
Пример #19
0
 public void AddRoom(Room room)
 {
     rooms.Add(room);
 }
Пример #20
0
 public Player(Room startRoom, Room finishRoom)
 {
     this.currentRoom = startRoom;
     this.finishRoom = finishRoom;
 }