Ejemplo n.º 1
0
        public void PresetMultiRand()
        {
            PresetMultiRand <int> testPicker = new PresetMultiRand <int>(5, 3, 1, 8);
            Mock <IRandom>        testRand   = new Mock <IRandom>(MockBehavior.Strict);
            List <int>            compare    = new List <int> {
                5, 3, 1, 8
            };

            Assert.That(testPicker.Roll(testRand.Object), Is.EquivalentTo(compare));
        }
Ejemplo n.º 2
0
        public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue)
        {
            int id = zoneContext.CurrentID;

            foreach (int floorId in SpreadPlan.DropPoints)
            {
                if (floorId != zoneContext.CurrentID)
                {
                    continue;
                }
                foreach (IGenPriority vaultStep in VaultSteps)
                {
                    queue.Enqueue(vaultStep.Priority, vaultStep.GetItem());
                }

                {
                    SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id);
                    PickerSpawner <ListMapGenContext, MapItem> constructedSpawns = new PickerSpawner <ListMapGenContext, MapItem>(new LoopedRand <MapItem>(itemListSlice, ItemAmount[id]));

                    List <IStepSpawner <ListMapGenContext, MapItem> > steps = new List <IStepSpawner <ListMapGenContext, MapItem> >();
                    steps.Add(constructedSpawns);
                    if (ItemSpawners.ContainsItem(id))
                    {
                        IStepSpawner <ListMapGenContext, MapItem> treasures = ItemSpawners[id].Copy();
                        steps.Add(treasures);
                    }
                    PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> > groupRand   = new PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> >(steps.ToArray());
                    RandomRoomSpawnStep <ListMapGenContext, MapItem>             detourItems = ItemPlacements[id].Copy();
                    detourItems.Spawn = new MultiStepSpawner <ListMapGenContext, MapItem>(groupRand);
                    queue.Enqueue(ItemPriority, detourItems);
                }


                SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id);
                if (mobListSlice.CanPick)
                {
                    //secret enemies
                    SpecificTeamSpawner specificTeam = new SpecificTeamSpawner();

                    MobSpawn newSpawn = mobListSlice.Pick(context.Rand).Copy();
                    specificTeam.Spawns.Add(newSpawn);

                    //use bruteforce clone for this
                    PlaceRandomMobsStep <ListMapGenContext> secretMobPlacement = MobPlacements[id].Copy();
                    secretMobPlacement.Spawn = new LoopedTeamSpawner <ListMapGenContext>(specificTeam, MobAmount[id]);
                    queue.Enqueue(MobPriority, secretMobPlacement);
                }
            }
        }
Ejemplo n.º 3
0
        public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue)
        {
            int id = zoneContext.CurrentID;

            foreach (int floorId in SpreadPlan.DropPoints)
            {
                if (floorId != zoneContext.CurrentID)
                {
                    continue;
                }
                {
                    SpawnList <AddBossRoomStep <ListMapGenContext> > bossListSlice = BossSteps.GetSpawnList(id);
                    if (!bossListSlice.CanPick)
                    {
                        return;
                    }
                    AddBossRoomStep <ListMapGenContext> bossStep = bossListSlice.Pick(context.Rand).Copy();
                    queue.Enqueue(BossRoomPriority, bossStep);
                }

                foreach (IGenPriority vaultStep in VaultSteps)
                {
                    queue.Enqueue(vaultStep.Priority, vaultStep.GetItem());
                }

                {
                    SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id);
                    PickerSpawner <ListMapGenContext, MapItem> constructedSpawns = new PickerSpawner <ListMapGenContext, MapItem>(new LoopedRand <MapItem>(itemListSlice, ItemAmount[id]));

                    IStepSpawner <ListMapGenContext, MapItem> treasures = ItemSpawners[id].Copy();

                    PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> > groupRand = new PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> >(constructedSpawns, treasures);

                    RandomRoomSpawnStep <ListMapGenContext, MapItem> detourItems = ItemPlacements[id].Copy();
                    detourItems.Spawn = new MultiStepSpawner <ListMapGenContext, MapItem>(groupRand);
                    queue.Enqueue(RewardPriority, detourItems);
                }
            }
        }