Exemplo n.º 1
0
    public void plotting_boardWithOneRectShape()
    {
        CaveBoard board = new CaveBoard(6, 6);
        IXShape   room  = new RectShape(new Cell(2, 2), new OIGrid(2, 2));

        room.setCellValue(0, 0, XTile.FLOOR);
        room.setCellValue(0, 1, XTile.FLOOR);
        room.setCellValue(1, 0, XTile.FLOOR);
        room.setCellValue(1, 1, XTile.FLOOR);
        board.addRoom(room);


        int[,] expected = new int[6, 6] {
            { 0, 0, 0, 0, 0, 0 },
            { 0, 0, 1, 1, 0, 0 },
            { 0, 1, 0, 0, 1, 0 },
            { 0, 1, 0, 0, 1, 0 },
            { 0, 0, 1, 1, 0, 0 },
            { 0, 0, 0, 0, 0, 0 }
        };

        ZeroOneCavePlotter plotter = new ZeroOneCavePlotter();

        plotter.applyOn(board);

        Assert.IsTrue(XTestUtils.areEquals(expected, plotter.result()));
    }
Exemplo n.º 2
0
        public void walkableCell_oneRoom3x3()
        {
            Room room = new Room(new Cell(0, 0), new Grid(3, 3));

            Cell[] result   = room.walkableCells(false);
            Cell[] expected = new Cell[1] {
                new Cell(1, 1)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 3
0
        public void walkableCell_ExcludingCellNextToWall_oneRoom4x4()
        {
            Room room = new Room(new Cell(0, 0), new Grid(5, 5));

            Cell[] result   = room.walkableCells(true);
            Cell[] expected = new Cell[1] {
                new Cell(2, 2)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 4
0
        public void walkableCell_horizontalCorridor()
        {
            Corridor corr = new Corridor(new Cell(0, 0), new Grid(3, 4), Corridor.Orientation.horizontal);

            Cell[] result   = corr.walkableCells(false);
            Cell[] expected = new Cell[4] {
                new Cell(1, 0), new Cell(1, 1), new Cell(1, 2), new Cell(1, 3)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 5
0
        public void walkableCell_ExcludingCellNextToWall_horizontalCorridor()
        {
            Corridor corr = new Corridor(new Cell(0, 0), new Grid(5, 1), Corridor.Orientation.horizontal);

            Cell[] result   = corr.walkableCells(true);
            Cell[] expected = new Cell[1] {
                new Cell(2, 0)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 6
0
        public void walkableCell_roomWithSouthIncomingCorridor()
        {
            Room     room = new Room(new Cell(0, 0), new Grid(3, 3));
            Corridor corr = new Corridor(new Cell(2, 0), new Grid(3, 3), Corridor.Orientation.vertical);

            room.setCorridorIncoming(corr);

            Cell[] result   = room.walkableCells(false);
            Cell[] expected = new Cell[1] {
                new Cell(1, 1)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 7
0
        public void walkableCell_oneRoom5x3withOneEastOutcomingCorridor3x3()
        {
            Room     room = new Room(new Cell(0, 0), new Grid(5, 3));
            Corridor corr = new Corridor(new Cell(1, 2), new Grid(3, 3), Corridor.Orientation.horizontal);

            room.setCorridorOutcoming(corr);

            Cell[] result   = room.walkableCells(false);
            Cell[] expected = new Cell[3] {
                new Cell(1, 1), new Cell(2, 1), new Cell(3, 1)
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 8
0
        public void plotting_detailed_oneCorridor3x4Horizontally()
        {
            Corridor room = new Corridor(new Cell(0, 0), new Grid(3, 4), Corridor.Orientation.horizontal);

            int[,] result = new int[3, 4];
            room.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[3, 4] {
                { 13, 2, 2, 12 },
                { 1, 1, 1, 1 },
                { 10, 4, 4, 11 }
            };

            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 9
0
        public void plotting_oneCorridor4x3Vertically()
        {
            Corridor corr = new Corridor(new Cell(0, 0), new Grid(4, 3), Corridor.Orientation.vertical);

            int[,] result = new int[4, 3];
            corr.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[4, 3] {
                { 11, 1, 10 },
                { 5, 1, 3 },
                { 5, 1, 3 },
                { 12, 1, 13 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 10
0
        public void plotting_detailed_oneRoom4x8()
        {
            Room room = new Room(new Cell(0, 0), new Grid(4, 8));

            int[,] result = new int[4, 8];
            room.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[4, 8] {
                { 6, 0, 2, 2, 2, 2, 0, 7 },
                { 0, 1, 1, 1, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 1, 1, 1, 0 },
                { 9, 0, 4, 4, 4, 4, 0, 8 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 11
0
        public void plotting_detailed_oneRoomAndOneCorridorHorizontalSharingBottomRightRoomVertex()
        {
            Room     room = new Room(new Cell(0, 0), new Grid(5, 4));
            Corridor corr = new Corridor(new Cell(2, 3), new Grid(3, 3), Corridor.Orientation.horizontal);

            room.setCorridorOutcoming(corr);
            corr.setSourceRoom(room);

            int[,] result = new int[5, 6];
            room.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[5, 6] {
                { 6, 0, 0, 7, 0, 0 },
                { 0, 1, 1, 0, 0, 0 },
                { 5, 1, 1, 13, 2, 12 },
                { 0, 1, 1, 1, 1, 1 },
                { 9, 0, 4, 4, 4, 11 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 12
0
        public void plotting_detailed_oneRoomAndOneIncomingHorizontalCorridorSharingTopRightRoomVertex()
        {
            Room     room = new Room(new Cell(0, 2), new Grid(5, 5));
            Corridor corr = new Corridor(new Cell(0, 0), new Grid(3, 3), Corridor.Orientation.horizontal);

            room.setCorridorIncoming(corr);
            corr.setDestinationRoom(room);

            int[,] result = new int[5, 7];
            corr.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[5, 7] {
                { 13, 2, 2, 2, 2, 0, 7 },
                { 1, 1, 1, 1, 1, 1, 0 },
                { 10, 4, 11, 1, 1, 1, 3 },
                { 0, 0, 0, 1, 1, 1, 0 },
                { 0, 0, 9, 0, 4, 0, 8 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 13
0
        public void plotting_oneRoomAndOneCorridorHorizontalSharingTopLeftRoomVertex()
        {
            Room     room = new Room(new Cell(0, 4), new Grid(5, 5));
            Corridor corr = new Corridor(new Cell(0, 0), new Grid(3, 3), Corridor.Orientation.horizontal);

            room.setCorridorOutcoming(corr);
            corr.setSourceRoom(room);

            int[,] result = new int[5, 9];
            room.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[5, 9] {
                { 13, 2, 12, 0, 6, 0, 2, 0, 7 },
                { 1, 1, 1, 0, 0, 1, 1, 1, 0 },
                { 10, 4, 11, 0, 5, 1, 1, 1, 3 },
                { 0, 0, 0, 0, 0, 1, 1, 1, 0 },
                { 0, 0, 0, 0, 9, 0, 4, 0, 8 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 14
0
        public void plotting_detailed_oneRoomAndOneCorridorVerticalSharingBottomRightRoomVertex()
        {
            Room     room = new Room(new Cell(0, 0), new Grid(4, 5));
            Corridor corr = new Corridor(new Cell(3, 2), new Grid(3, 3), Corridor.Orientation.vertical);

            room.setCorridorOutcoming(corr);
            corr.setSourceRoom(room);

            int[,] result = new int[6, 5];
            room.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[6, 5] {
                { 6, 0, 2, 0, 7 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 3 },
                { 9, 0, 11, 1, 3 },
                { 0, 0, 5, 1, 3 },
                { 0, 0, 12, 1, 13 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }
Exemplo n.º 15
0
        public void plotting_detailed_twoRoomsWithoutOverlapping()
        {
            Room room5x5 = new Room(new Cell(0, 0), new Grid(5, 5));
            Room room4x4 = new Room(new Cell(6, 0), new Grid(4, 4));

            int[,] result = new int[10, 5];
            room5x5.plotOn(result, new DetailedTilesPlotter());
            room4x4.plotOn(result, new DetailedTilesPlotter());

            int[,] expected = new int[10, 5] {
                { 6, 2, 2, 0, 7 },
                { 0, 1, 1, 1, 0 },
                { 5, 1, 1, 1, 3 },
                { 0, 1, 1, 1, 0 },
                { 9, 0, 4, 0, 8 },
                { 0, 0, 0, 0, 0 },
                { 6, 0, 0, 7, 0 },
                { 0, 1, 1, 0, 0 },
                { 0, 1, 1, 0, 0 },
                { 9, 0, 0, 8, 0 }
            };
            Assert.IsTrue(XTestUtils.areEquals(expected, result));
        }