Пример #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 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 + " . . . . . . . . . . . .");
        }
Пример #3
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);
 }
Пример #4
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);
 }
Пример #5
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);
 }