Example #1
0
        protected override void AfterDestroy()
        {
            base.AfterDestroy();

            // Remove all particle systems from the manager and destroy it
            if (_particleSystemManager != null)
            {
                _particleSystemManager.RemoveAllParticleSystems();
                _particleSystemManager = null;
            }

            // Destroy all of the particle systems
            if (_debrisParticleSystem != null)
            {
                _debrisParticleSystem.Destroy();
                _debrisParticleSystem = null;
            }

            if (_fireSmokeParticleSystem != null)
            {
                _fireSmokeParticleSystem.Destroy();
                _fireSmokeParticleSystem = null;
            }

            if (_flashParticleSystem != null)
            {
                _flashParticleSystem.Destroy();
                _flashParticleSystem = null;
            }

            if (_flyingSparksParticleSystem != null)
            {
                _flyingSparksParticleSystem.Destroy();
                _flyingSparksParticleSystem = null;
            }

            if (_roundSparksParticleSystem != null)
            {
                _roundSparksParticleSystem.Destroy();
                _roundSparksParticleSystem = null;
            }

            if (_shockwaveParticleSystem != null)
            {
                _shockwaveParticleSystem.Destroy();
                _shockwaveParticleSystem = null;
            }

            if (_smokeTrailsParticleSystem != null)
            {
                _smokeTrailsParticleSystem.Destroy();
                _smokeTrailsParticleSystem = null;
            }
        }
Example #2
0
        /// <summary>
        /// Initialize all of the particle systems used by this particle system class.
        /// </summary>
        private void AutoInitializeOtherParticleSystems(SpriteBatch spriteBatch)
        {
            _particleSystemManager = new ParticleSystemManager();

            // Create all the particle systems
            _debrisParticleSystem = new ExplosionDebrisParticleSystem(this.Game);
            _fireSmokeParticleSystem = new ExplosionFireSmokeParticleSystem(this.Game);
            _flashParticleSystem = new ExplosionFlashParticleSystem(this.Game);
            _flyingSparksParticleSystem = new ExplosionFlyingSparksParticleSystem(this.Game);
            _roundSparksParticleSystem = new ExplosionRoundSparksParticleSystem(this.Game);
            _shockwaveParticleSystem = new ExplosionShockwaveParticleSystem(this.Game);
            _smokeTrailsParticleSystem = new ExplosionSmokeTrailsParticleSystem(this.Game);

            // Specify the order the particle systems should be drawn in
            _debrisParticleSystem.DrawOrder = 100;
            _fireSmokeParticleSystem.DrawOrder = 200;
            _flashParticleSystem.DrawOrder = 200;
            _flyingSparksParticleSystem.DrawOrder = 200;
            _roundSparksParticleSystem.DrawOrder = 200;
            _shockwaveParticleSystem.DrawOrder = 200;
            _smokeTrailsParticleSystem.DrawOrder = 200;

            // Add all of the particle systems to the manager
            _particleSystemManager.AddParticleSystem(_debrisParticleSystem);
            _particleSystemManager.AddParticleSystem(_fireSmokeParticleSystem);
            _particleSystemManager.AddParticleSystem(_flashParticleSystem);
            _particleSystemManager.AddParticleSystem(_flyingSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_roundSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_shockwaveParticleSystem);
            _particleSystemManager.AddParticleSystem(_smokeTrailsParticleSystem);

            // Initialize all of the particle systems
			_particleSystemManager.AutoInitializeAllParticleSystems(this.GraphicsDevice, this.ContentManager, spriteBatch);

			// Turn off Lerping on the particle system emitters so that they don't trail from one explosion location to the next.
			_debrisParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_fireSmokeParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_flashParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_flyingSparksParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_roundSparksParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_shockwaveParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_smokeTrailsParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
        }