/// <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; }
protected override void LoadContent() { explosionParticles = new ExplosionParticleSystem(game, game.Content); explosionSmokeParticles = new ExplosionSmokeParticleSystem(game, game.Content); projectileTrailParticles = new ProjectileTrailParticleSystem(game, game.Content); // Set the draw order so the explosions and fire // will appear over the top of the smoke. explosionSmokeParticles.DrawOrder = 200; projectileTrailParticles.DrawOrder = 300; explosionParticles.DrawOrder = 400; game.Components.Add(explosionParticles); game.Components.Add(explosionSmokeParticles); game.Components.Add(projectileTrailParticles); explosionSFX = game.Content.Load<SoundEffect>("Audio\\Barrel Exploding"); }
public Bullet(Game1 g, ParticleSystem explosionParticles, ParticleSystem explosionSmokeParticles, ParticleSystem projectileTrailParticles, Vector3 origin, Vector3 initialVelocity, SoundEffect Explosion) : base(g) { game = g; bulletState = BulletState.Unexploded; this.position = origin; this.velocity = initialVelocity; game.physicsEngine.AddPhysicsObject(this); this.explosionParticles = explosionParticles; this.explosionSmokeParticles = explosionSmokeParticles; this.explosionAge = float.NaN; this.explosionLifetime = (float)explosionParticles.Settings.Duration.TotalSeconds + explosionParticles.Settings.DurationRandomness; // Use the particle emitter helper to output our trail particles. trailEmitter = new ParticleEmitter(projectileTrailParticles, trailParticlesPerSecond, position); explosion = Explosion; }