/// <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 = Vector3.Zero; 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); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //Initialise objects camera = new Camera(); spaceship = new Spaceship(); planet = new Planet(); fuelCells = new FuelCell[numFuelCells]; turrets = new Turret[numTurrets]; readyMissiles = new List<Missile>(); firedMissiles = new List<Missile>(); boundingSphere = new GameObject(); explosions = new List<Explosion>(); //Initialise particle effect variables fireParticles = new FireParticleSystem(this, Content); fireParticles.DrawOrder = 500; Components.Add(fireParticles); explosionParticles = new ExplosionParticleSystem(this, Content); explosionParticles.DrawOrder = 500; Components.Add(explosionParticles); base.Initialize(); }
Vector3 position; //The explosions position in space #endregion Fields #region Constructors /// <summary> /// Creates a new game explosion. /// </summary> /// <param name="particleSystem">The particle system to emit particles with</param> /// <param name="position">The position to place the particle emitter</param> public Explosion(ParticleSystem particleSystem, Vector3 position) { Age = 0; this.position = position; explosionParticleEmitter = new ParticleEmitter(particleSystem, 1000, position); }
/// <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; }