/// <summary> /// Add a certain number of things from an array of thing types to a map. /// </summary> /// <param name="map">The Doom map on which to add things</param> /// <param name="count">The number of things to add</param> /// <param name="generationFlags">Special flags for thing generation</param> /// <param name="thingTypes">Array of thing types to select from</param> private void AddThings(DoomMap map, int count, ThingsGeneratorFlags generationFlags, params int[] thingTypes) { if ((count < 1) || (thingTypes.Length == 0)) { return; } for (int i = 0; i < count; i++) { if (FreeTiles.Count == 0) { return; } ThingOptions options = ThingOptions.AllSkills; switch (generationFlags) { case ThingsGeneratorFlags.MoreThingsInEasyMode: if (Toolbox.RandomInt(4) == 0) { options = ThingOptions.Skill12 | ThingOptions.Skill3; } else if (Toolbox.RandomInt(3) == 0) { options = ThingOptions.Skill12; } break; case ThingsGeneratorFlags.MoreThingsInHardMode: if (Toolbox.RandomInt(3) == 0) { options = ThingOptions.Skill3 | ThingOptions.Skill45; } else if (Toolbox.RandomInt(2) == 0) { options = ThingOptions.Skill45; } break; } int thingType = Toolbox.RandomFromArray(thingTypes); Point pt = Toolbox.RandomFromList(FreeTiles); AddThing(map, pt.X, pt.Y, thingType, Toolbox.RandomInt(360), options); FreeTiles.Remove(pt); } }
/// <summary> /// Adds a random number of things from a certain ThingCategory. /// </summary> /// <param name="map">The Doom map on which to add things</param> /// <param name="thingCategory">The thing category from which to pick thing types</param> /// <param name="minCount">Min number of things to add</param> /// <param name="maxCount">Max number of things to add</param> /// <param name="generationFlags">Special flags for thing generation</param> private void AddThings(DoomMap map, ThingCategory thingCategory, int minCount, int maxCount, ThingsGeneratorFlags generationFlags = 0) { int count = Toolbox.RandomInt(minCount, maxCount + 1); AddThings(map, count, generationFlags, Preferences.ThingsTypes[(int)thingCategory]); }