/// <summary> /// Constructs a new particle emitter object. /// </summary> public ParticleEmitter(ParticleSystem particleSystem, float particlesPerSecond, Vector3 initialPosition) { this.particleSystem = particleSystem; timeBetweenParticles = 1.0f / particlesPerSecond; previousPosition = initialPosition; }
/// <summary> /// Constructs a new projectile. /// </summary> public Projectile(ParticleSystem explosionParticles, ParticleSystem explosionSmokeParticles, ParticleSystem projectileTrailParticles) { this.explosionParticles = explosionParticles; this.explosionSmokeParticles = explosionSmokeParticles; // Start at the origin, firing in a random (but roughly upward) direction. position = new Vector3(326, 5, -281); velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange; velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; // Use the particle emitter helper to output our trail particles. trailEmitter = new ParticleEmitter(projectileTrailParticles, trailParticlesPerSecond, position); }
void InitializeParticles() { // Construct our particle system components. explosionParticles = new ExplosionParticleSystem(parentGame, parentGame.Content); explosionSmokeParticles = new ExplosionSmokeParticleSystem(parentGame, parentGame.Content); shotSmokeParticles = new ShotSmokeParticleSystem(parentGame, parentGame.Content); shotExplosionParticles = new ShotExplosionParticleSystem(parentGame, parentGame.Content); ringExplosionParticles = new RingExplosionParticleSystem(parentGame, parentGame.Content); projectileTrailParticles = new ProjectileTrailParticleSystem(parentGame, parentGame.Content); smokePlumeParticles = new SmokePlumeParticleSystem(parentGame, parentGame.Content); fireParticles = new FireParticleSystem(parentGame, parentGame.Content); sparkParticles = new SparkParticleSystem(parentGame, parentGame.Content); concreteParticles = new ConcreteParticleSystem(parentGame, parentGame.Content); buildingColumn = new BuildingColumnParticles(parentGame, parentGame.Content); buildingDisk = new BuildingDiskParticles(parentGame, parentGame.Content); // Set the draw order so the explosions and fire // will appear over the top of the smoke. smokePlumeParticles.DrawOrder = 100; explosionSmokeParticles.DrawOrder = 200; shotSmokeParticles.DrawOrder = 250; projectileTrailParticles.DrawOrder = 300; explosionParticles.DrawOrder = 400; shotExplosionParticles.DrawOrder = 450; fireParticles.DrawOrder = 500; ringExplosionParticles.DrawOrder = 510; concreteParticles.DrawOrder = 510; sparkParticles.DrawOrder = 520; buildingColumn.DrawOrder = 600; buildingDisk.DrawOrder = 620; // Register the particle system components. Particles = new List<ParticleSystem>(); Particles.Add(explosionParticles); Particles.Add(explosionSmokeParticles); Particles.Add(shotSmokeParticles); Particles.Add(shotExplosionParticles); Particles.Add(projectileTrailParticles); Particles.Add(smokePlumeParticles); Particles.Add(fireParticles); Particles.Add(ringExplosionParticles); Particles.Add(concreteParticles); Particles.Add(sparkParticles); Particles.Add(buildingColumn); Particles.Add(buildingDisk); for (int i = 0; i < Particles.Count; ++i) Particles[i].Initialize(); }