コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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); });
        }
コード例 #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);
        }
コード例 #5
0
        public void GetHallTouchRangeLargeRoomMiddle(int fulfill1, int fulfill2, int rangeMin, int rangeMax)
        {
            string[] inGrid =
            {
                "A.A.A.0",
                ". . . .",
                "A.A.A.0",
                ". . . .",
                "0.0.0.0",
            };
            int width = 16;

            bool[] fulfillable = new bool[width];
            fulfillable[fulfill1] = true;
            fulfillable[fulfill2] = true;

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid, 6, 4);
            Mock <IRandom>    testRand  = new Mock <IRandom>(MockBehavior.Strict);
            TestGridRoomGen   testGen   = (TestGridRoomGen)floorPlan.PublicArrayRooms[0].RoomGen;

            testGen.PrepareSize(testRand.Object, new Loc(width, 6));
            testGen.PrepareFulfillableBorder(Dir4.Down, fulfillable);
            testGen.SetLoc(new Loc(2, 1));
            IntRange bounds        = floorPlan.GetHallTouchRange(testGen, Dir4.Down, 1);
            IntRange compareBounds = new IntRange(rangeMin, rangeMax);

            Assert.That(bounds, Is.EqualTo(compareBounds));
        }
コード例 #6
0
        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); });
        }
コード例 #7
0
        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); });
        }
コード例 #8
0
        public void SetHallInDirs(Dir4 dir, int expectedOut)
        {
            // valid/invalid dir
            string[] inGrid =
            {
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
                ". . . .",
                "0.0.0.0",
            };

            string[] outGrid   = null;
            bool     exception = false;

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

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

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

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

            default:
                exception = true;
                break;
            }

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);
            var gen = new TestGridRoomGen((char)0);

            if (exception)
            {
                if (dir == Dir4.None)
                {
                    Assert.Throws <ArgumentException>(() => { floorPlan.SetHall(new LocRay4(1, 1, dir), gen); });
                }
                else
                {
                    Assert.Throws <ArgumentOutOfRangeException>(() => { floorPlan.SetHall(new LocRay4(1, 1, dir), gen); });
                }
                return;
            }
            else
            {
                floorPlan.SetHall(new LocRay4(1, 1, dir), gen);
            }

            TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid);

            TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);

            // set existing hall to null
        }