public void AddFireworks() { Vector2 position = new Vector2( fSpriteBatch.GraphicsDevice.Viewport.Width / 2, fSpriteBatch.GraphicsDevice.Viewport.Height); Vector2 velocity = new Vector2( Convert.ToSingle((fRandom.NextDouble() - 0.5f) * 40.0f), Convert.ToSingle(-50.0 - 30 * fRandom.NextDouble())); IFireEngine engine = fFireEngines[fRandom.Next(fFireEngines.Length)]; IFirework firework = engine.CreateFirework(); firework.SetStartPosition(position, velocity); fFireworks.Add(firework); }
public void AddFireworks(int count) { int deltaX = fSpriteBatch.GraphicsDevice.Viewport.Width / (count + 1); Vector2 velocity = new Vector2( Convert.ToSingle((fRandom.NextDouble() - 0.5f) * 40.0f), Convert.ToSingle(-50.0 - 30 * fRandom.NextDouble())); int x = 0; int engineIndex = fRandom.Next(fFireEngines.Length); for (int i = 0; i < count; i++) { x += deltaX; Vector2 position = new Vector2( x, fSpriteBatch.GraphicsDevice.Viewport.Height); IFireEngine engine = fFireEngines[engineIndex]; IFirework firework = engine.CreateFirework(); firework.SetStartPosition(position, velocity); fFireworks.Add(firework); } }