Пример #1
0
        public static List <BgItem> GenerateRandomList(Random random, int start, int maxSize)
        {
            var list     = new List <BgItem>();
            var lastItem = new BgItem {
                Code = "start", Offset = start
            };

            list.Add(lastItem);
            do
            {
                var pOffset = random.Next(MinimumPatternOffset, MaximumPatternOffset + 1);
                var pattern = BgPatterns[random.Next(0, BgPatterns.Count)];
                lastItem = new BgItem {
                    Code = pattern[0], Offset = lastItem.Offset + pOffset
                };
                list.Add(lastItem);
                foreach (var bgType in pattern.Skip(1))
                {
                    var iOffset = random.Next(MinimumInnerOffset, MaximumInnerOffset + 1);
                    lastItem = new BgItem {
                        Code = bgType, Offset = lastItem.Offset + iOffset
                    };
                    list.Add(lastItem);
                }
            } while (lastItem.Offset <= maxSize);
            lastItem = new BgItem {
                Code = "finish", Offset = LevelMap.MaximumScore
            };
            list.Add(lastItem);
            return(list);
        }
Пример #2
0
        public void GenerateRandom(Random random)
        {
            // Background
            Background = BgItem.GenerateRandomList(random, BackgroundStart, BackgroundMaxSize);

            // Events
            Events = LevelEvent.GenerateRandomList(random, EventsMinScore, EventsMaxScore);
        }