Exemplo n.º 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;
            }
        }