Ejemplo n.º 1
0
        public void RandomizeRoomSpriteGroups(SpriteGroupCollection spriteGroups)
        {
            foreach (var r in Rooms.Where(x => RoomIdConstants.DontRandomizeRooms.Contains(x.RoomId) == false))
            {
                List <SpriteRequirement> doNotUpdateSprites = spriteRequirementCollection
                                                              .DoNotRandomizeSprites
                                                              .Where(x => x.CanSpawnInRoom(r) &&
                                                                     r.Sprites.Select(y => y.SpriteId).ToList().Contains(x.SpriteId)
                                                                     )
                                                              .ToList();

                var possibleSpriteGroups = spriteGroups.GetPossibleDungeonSpriteGroups(r, doNotUpdateSprites).ToList();

                //Debug.Assert(possibleSpriteGroups.Count > 0);
                if (possibleSpriteGroups.Count > 0)
                {
                    r.GraphicsBlockId = possibleSpriteGroups[rand.Next(possibleSpriteGroups.Count)].DungeonGroupId;
                }
            }

            // force any rooms we need to
            foreach (var sg in spriteGroups.SpriteGroups.Where(x => x.ForceRoomsToGroup != null && x.ForceRoomsToGroup.Count > 0))
            {
                foreach (var forcedR in Rooms.Where(x => sg.ForceRoomsToGroup.Contains(x.RoomId)))
                {
                    forcedR.GraphicsBlockId = sg.DungeonGroupId;
                }
            }
        }
Ejemplo n.º 2
0
        public void RandomizeRoomSpriteGroups(SpriteGroupCollection spriteGroups, OptionFlags optionFlags)
        {
            // skip rooms that are set to do not randomize because that would be pointless to process them
            foreach (var r in Rooms)
            {
                if (RoomIdConstants.DontRandomizeRooms.Contains(r.RoomId))
                {
                    continue;
                }

                if (optionFlags.EasyModeEscape && RoomIdConstants.NoSpecialEnemiesRoomsInStandardMode.Contains(r.RoomId))
                {
                    continue;
                }

                List <SpriteRequirement> doNotUpdateSprites = spriteRequirementCollection
                                                              .DoNotRandomizeSprites
                                                              .Where(x => x.CanSpawnInRoom(r) &&
                                                                     r.Sprites.Select(y => y.SpriteId).ToList().Contains(x.SpriteId)
                                                                     )
                                                              .ToList();

                /* TODO: put this back after I figure out what I screwed up
                 * List<SpriteRequirement> forcedSprites = spriteRequirementCollection.SpriteRequirements
                 *                          .Where(x => false == x.CanBeRandomizedInRoom(r))
                 *                          .Where(x => x.CanSpawnInRoom(r)
                 *                                      && r.Sprites.Select(y => y.SpriteId).ToList().Contains(x.SpriteId)
                 *                              )
                 *                          .ToList();
                 * doNotUpdateSprites.AddRange(forcedSprites);
                 *
                 * //*/


                var possibleSpriteGroups = spriteGroups.GetPossibleDungeonSpriteGroups(r, doNotUpdateSprites).ToList();

                //Debug.Assert(possibleSpriteGroups.Count > 0);
                if (possibleSpriteGroups.Count > 0)
                {
                    r.GraphicsBlockId = possibleSpriteGroups[rand.Next(possibleSpriteGroups.Count)].DungeonGroupId;
                }
            }

            // force any rooms we need to
            foreach (var sg in spriteGroups.SpriteGroups.Where(x => x.ForceRoomsToGroup != null && x.ForceRoomsToGroup.Count > 0))
            {
                foreach (var forcedR in Rooms.Where(x => sg.ForceRoomsToGroup.Contains(x.RoomId)))
                {
                    forcedR.GraphicsBlockId = sg.DungeonGroupId;
                }
            }
        }