public void AddBigRoomToEmptySpace()
        {
            // add big room to empty space
            string[] inGrid =
            {
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
            };

            string[] outGrid =
            {
                "0.0.0.0",
                ". . . .",
                "0.A.A.A",
                ". . . .",
                "0.A.A.A",
            };

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('A');

            floorPlan.AddRoom(new Rect(1, 1, 3, 2), gen);
            TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid);

            TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);
        }
        public void AddBigRoomToSurrounded()
        {
            // add room to a room/hall-ridden floor where halls just barely avoid the room
            string[] inGrid =
            {
                "A#B#C#D",
                "# # # #",
                "E#0.0#F",
                "# . . #",
                "G#0.0#H",
            };

            string[] outGrid =
            {
                "A#B#C#D",
                "# # # #",
                "E#I.I#F",
                "# . . #",
                "G#I.I#H",
            };

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('I');

            floorPlan.AddRoom(new Rect(1, 1, 2, 2), gen);

            TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid);

            TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);
        }
        public void AddBigRoomToHall(int gridType)
        {
            // add small room on big room
            string[] inGrid = null;

            switch (gridType)
            {
            case 0:
                inGrid = new string[]
                {
                    "0.0.0.0",
                    ". . . .",
                    "0.0#0.0",
                    ". . . .",
                    "0.0.0.0",
                };
                break;

            case 1:
                inGrid = new string[]
                {
                    "0.0.0.0",
                    ". . . .",
                    "0.0.0.0",
                    ". # . .",
                    "0.0.0.0",
                };
                break;

            case 2:
                inGrid = new string[]
                {
                    "0.0.0.0",
                    ". . . .",
                    "0.0.0.0",
                    ". . # .",
                    "0.0.0.0",
                };
                break;

            case 3:
                inGrid = new string[]
                {
                    "0.0.0.0",
                    ". . . .",
                    "0.0.0.0",
                    ". . . .",
                    "0.0#0.0",
                };
                break;

            default:
                throw new Exception("Unexpected Case");
            }

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('A');

            Assert.Throws <InvalidOperationException>(() => { floorPlan.AddRoom(new Rect(1, 1, 2, 2), gen); });
        }
Beispiel #4
0
        public void AddRoomToEmptySpace()
        {
            // add to empty space
            string[] inGrid =
            {
                "0.0.0",
                ". . .",
                "0.0.0",
            };

            string[] outGrid =
            {
                "0.A.0",
                ". . .",
                "0.0.0",
            };

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('A');

            floorPlan.AddRoom(new Rect(1, 0, 1, 1), gen, new ComponentCollection());
            TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid);

            TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);
        }
        public void AddRoomOutOfRange(int x, int y, int w, int h)
        {
            // out of range
            string[] inGrid =
            {
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
            };

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('A');

            Assert.Throws <ArgumentOutOfRangeException>(() => { floorPlan.AddRoom(new Rect(x, y, w, h), gen); });
        }
        public void AddCrossingRooms()
        {
            // add small room on big room
            string[] inGrid =
            {
                "0.0.0.0",
                ". . . .",
                "0.A.A.A",
                ". . . .",
                "0.A.A.A",
            };

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen('B');

            Assert.Throws <InvalidOperationException>(() => { floorPlan.AddRoom(new Rect(1, 0, 2, 2), gen); });
        }