public void GenerateRandom(Random random) { // Background Background = BgItem.GenerateRandomList(random, BackgroundStart, BackgroundMaxSize); // Events Events = LevelEvent.GenerateRandomList(random, EventsMinScore, EventsMaxScore); }
public static List <LevelEvent> GenerateRandomList(Random random, int minScore, int maxScrore) { var list = new List <LevelEvent>(); var lastItem = new LevelEvent { Score = minScore }; do { var score = random.Next(MinimumDeltaScore, MaximumDeltaScore + 1) + lastItem.Score; var type = (EventType)random.Next(1, ExclusiveUpperBoundForEventNumber); var duration = random.Next(MinimumDuration, MaximumDuration); lastItem = new LevelEvent { Type = type, Score = score, Duration = duration }; list.Add(lastItem); } while (lastItem.Score <= maxScrore); return(list); }