/// <summary> /// Adds objects only once to the passed collection. Should be used once. /// </summary> /// <param name="objects"></param> public IEnumerable <EnvironmentObject> SeedInitialObjects() { var generatedObjects = new List <EnvironmentObject>(); for (int i = 0; i < StaticStarCount; i++) { int x = this.randomGenerator.Next(0, this.worldWidth); int y = this.randomGenerator.Next(0, 20); var envObject = new Star(x, y, 1, 1); generatedObjects.Add(envObject); } for (int i = 0; i < FallingStarCount; i++) { int x = this.randomGenerator.Next(0, this.worldWidth); int y = this.randomGenerator.Next(0, 20); int[] dirPoss = { 1, -2 }; int dirIndex = this.randomGenerator.Next(0, 2); var envObject = new FallingStar(x, y, 4, 4, new Point(dirPoss[dirIndex], 1)); generatedObjects.Add(envObject); } for (int i = 0; i < ExplodingStarCount; i++) { int x = this.randomGenerator.Next(0, this.worldWidth); int y = this.randomGenerator.Next(0, 20); int[] dirPoss = { 1, -2 }; int dirIndex = this.randomGenerator.Next(0, 2); var envObject = new ExplodingFallingStar(x, y, 4, 4, new Point(dirPoss[dirIndex], 1)); generatedObjects.Add(envObject); } generatedObjects.Add(new Ground(0, 25, 50, 2, '#')); return(generatedObjects); }
/// <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); } } }