private static void generateDungeonContent(Dungeon d) { float loc = 0.08f + (float)(rand.NextDouble() * 0.04); while (loc <= 0.9f) { Combat combat = new Combat(); combat.Location = loc; d.Encounters.Add(combat); loc += 0.06f + (float)(rand.NextDouble() * 0.12); } }
public static Dungeon generateRandomDungeon(int averageLevel) { Dungeon dungeon = new Dungeon(); //Calculate the variance in levels, the generated dungeons level is level + (0 to variance) int levelVariance = 1 + (int)(Math.Sqrt(averageLevel)); int level = averageLevel + (int)((levelVariance) * rand.NextDouble()); dungeon.RecommendedLevel = level; dungeon.Hazardousness = GenerateRandomHazardousness(level); dungeon.Enviroment = Dungeon.enviroments[UnityEngine.Random.Range(0, Dungeon.enviroments.Length)]; dungeon.Name = Dungeon.hazardousnessLevels[dungeon.Hazardousness] + " " + dungeon.Enviroment + " of " + adjectives[UnityEngine.Random.Range(0, adjectives.Length)]; generateDungeonContent(dungeon); return dungeon; }