/// <summary>
        /// Dynamically adds objects to the passed collection.
        /// </summary>
        /// <param name="objects"></param>
        public void DynamicallyAdd(List<EnvironmentObject> objects)
        {
            // for (int i = 0; i < SnowflakeCount; i++)
            // {
            //     int generateFlag = rnd.Next(0, 5);
            //
            //     if (generateFlag == 1)
            //     {
            //         int x = rnd.Next(0, WorldWidth);
            //         var envObject = new Snowflake(x, 1, 1, 1, new Point(0, 1));
            //
            //         objects.Add(envObject);
            //     }
            // }

            for (int i = 0; i < SnowflakeCount; i++)
            {
                int generateFlag = rnd.Next(0, 30);

                if (generateFlag == 1)
                {
                    int x = rnd.Next(0, WorldWidth);
                    int y = rnd.Next(0, WorldHeight - 10);
                    var envObject = new UnstableStar(x, y, 1, 1, new Point(rnd.Next(2) - 1, 1));

                    objects.Add(envObject);
                }
            }

            for (int i = 0; i < SnowflakeCount; i++)
            {
                int generateFlag = rnd.Next(0, 30);

                if (generateFlag == 1)
                {
                    int x = rnd.Next(0, WorldWidth);
                    int y = rnd.Next(0, WorldHeight - 10);
                    var envObject = new FallingStar(x, y, 1, 1, new Point(rnd.Next(2) - 1, 1));

                    objects.Add(envObject);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the next portion of objects to the passed collection. Can be used many times.
        /// </summary>
        /// <param name="objects"></param>
        public IEnumerable <EnvironmentObject> GenerateNextObjects()
        {
            var generatedObjects = new List <EnvironmentObject>();

            for (int i = 0; i < ObjectsCount; i++)
            {
                int generateFlag = this.randomGenerator.Next(0, 20);

                if (generateFlag == 1)
                {
                    int direction = this.randomGenerator.Next(-1, 2);

                    int x         = this.randomGenerator.Next(0, this.worldWidth);
                    int y         = this.randomGenerator.Next(0, 20);
                    var envObject = new UnstableStar(x, y, 1, 1, new Point(direction, 1));

                    generatedObjects.Add(envObject);
                }
            }

            return(generatedObjects);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds objects only once to the passed collection.
        /// </summary>
        /// <param name="objects"></param>
        public void Initiliaze(List<EnvironmentObject> objects)
        {
            objects.Add(new Ground(0, 25, 50, 2));

            Random rnd = new Random();

            for (int i = 0; i < StarCount; i++)
            {
                int x = rnd.Next(0, WorldWidth);
                int y = rnd.Next(0, 24);
                var envObject = new Star(x, y, 1, 1);

                objects.Add(envObject);
            }

            for (int i = 0; i < UnstableStarCount; i++)
            {
                int x = rnd.Next(0, WorldWidth);
                int y = rnd.Next(0, 24);
                var envObject = new UnstableStar(x, y, 1, 1);

                objects.Add(envObject);
            }
        }