Beispiel #1
0
        public override void ApplyToPath(IRandom rand, FloorPlan floorPlan)
        {
            //attempt 10 times
            for (int kk = 0; kk < 10; kk++)
            {
                //add the boss room

                FloorPathBranch <T> .ListPathBranchExpansion?expandBossResult = this.ChooseRoomExpansion(rand, floorPlan);

                if (!expandBossResult.HasValue)
                {
                    continue;
                }

                var bossExpansion = expandBossResult.Value;

                RoomHallIndex from = bossExpansion.From;
                if (bossExpansion.Hall != null)
                {
                    floorPlan.AddHall(bossExpansion.Hall, this.BossHallComponents.Clone(), from);
                    from = new RoomHallIndex(floorPlan.HallCount - 1, true);
                }

                floorPlan.AddRoom(bossExpansion.Room, this.BossComponents.Clone(), from);

                RoomHallIndex bossFrom = new RoomHallIndex(floorPlan.RoomCount - 1, false);

                GenContextDebug.DebugProgress("Extended with Boss Room");

                //now, attempt to add the treasure room and remove the previous rooms if failed


                FloorPathBranch <T> .ListPathBranchExpansion?expansionResult = FloorPathBranch <T> .ChooseRoomExpansion(this.PrepareTreasureRoom, 100, rand, floorPlan, new List <RoomHallIndex>() { bossFrom });

                if (!expansionResult.HasValue)
                {
                    //remove the previously added boss room and hall
                    floorPlan.EraseRoomHall(bossFrom);
                    floorPlan.EraseRoomHall(from);
                    continue;
                }

                var vaultExpansion = expansionResult.Value;

                if (vaultExpansion.Hall != null)
                {
                    floorPlan.AddHall(vaultExpansion.Hall, this.VaultHallComponents.Clone(), bossFrom);
                    bossFrom = new RoomHallIndex(floorPlan.HallCount - 1, true);
                }

                floorPlan.AddRoom(vaultExpansion.Room, this.VaultComponents.Clone(), bossFrom);

                GenContextDebug.DebugProgress("Extended with Treasure Room");

                return;
            }
        }
Beispiel #2
0
        public void NavigationService_weighs_values()
        {
            RoomService roomService = NSubstitute.Substitute.For <RoomService>();
            FloorPlan   plan        = new FloorPlan(20, 20, fill: true);

            RoomPlan roomPlan = new RoomPlan
            {
                Name       = "Test",
                Width      = 5,
                Height     = 5,
                WallValue  = 20,
                FloorValue = 1,
                DoorTile   = new DoorTile(4, 2, cost: 3, notes: "Door")
            };
            IFloorRoom room = roomService.GenerateRoom(roomPlan);

            plan.AddRoom(room, new Location(3, 12));

            var display = plan.Print();

            Debug.WriteLine(display);

            NavigationService navService = NSubstitute.Substitute.For <NavigationService>(plan);
            var path = navService.FindPath(new Location(1, 1), new Location(5, 14));

            display = plan.Print(path);
            Debug.Write(display);
        }