}   // end of ParticleSystemManager UnloadContent()

        public void DeviceReset(GraphicsDevice device)
        {
            SharedEmitterManager.DeviceReset(device);

            BaseSpriteEmitter.DeviceReset(device);

            ExplosionEmitter.DeviceReset(device);
            FlowerEmitter.DeviceReset(device);
            HeartEmitter.DeviceReset(device);
            SmokeEmitter.DeviceReset(device);
            StarEmitter.DeviceReset(device);
            SteamEmitter.DeviceReset(device);
            SwearEmitter.DeviceReset(device);
            WreathEmitter.DeviceReset(device);

            BeamExplosionEmitter.DeviceReset(device);
            BeamSmokeEmitter.DeviceReset(device);
            ScanExplosionEmitter.DeviceReset(device);
            ScanSmokeEmitter.DeviceReset(device);
            RoverScanExplosionEmitter.DeviceReset(device);
            RoverScanSmokeEmitter.DeviceReset(device);
            InspectExplosionEmitter.DeviceReset(device);
            InspectSmokeEmitter.DeviceReset(device);
            FanEmitter.DeviceReset(device);
            InkEmitter.DeviceReset(device);
        }
        public void UnloadContent()
        {
            effectCache2d.UnLoad();
            BokuGame.Release(ref effect2d);
            BokuGame.Release(ref effect3d);

            SharedEmitterManager.UnloadContent();

            BaseSpriteEmitter.UnloadContent();

            ExplosionEmitter.UnloadContent();  // Remove the static texture instance.
            FlowerEmitter.UnloadContent();     // Remove the static texture instance.
            HeartEmitter.UnloadContent();      // Remove the static texture instance.
            SmokeEmitter.UnloadContent();      // Remove the static texture instance.
            StarEmitter.UnloadContent();
            SteamEmitter.UnloadContent();
            SwearEmitter.UnloadContent();
            WreathEmitter.UnloadContent();

            BeamExplosionEmitter.UnloadContent();
            BeamSmokeEmitter.UnloadContent();
            ScanExplosionEmitter.UnloadContent();
            ScanSmokeEmitter.UnloadContent();
            RoverScanExplosionEmitter.UnloadContent();
            RoverScanSmokeEmitter.UnloadContent();
            InspectExplosionEmitter.UnloadContent();
            InspectSmokeEmitter.UnloadContent();
            FanEmitter.UnloadContent();
            InkEmitter.UnloadContent();
        }   // end of ParticleSystemManager UnloadContent()
        // c'tor
        public ParticleSystemManager()
        {
            emitterList = new List <BaseEmitter>();

            SharedEmitterManager sharedEmitterManager = new SharedEmitterManager(this);

            sharedEmitterManager.Usage = BaseEmitter.Use.Distort | BaseEmitter.Use.Regular;
            sharedEmitterManager.AddToManager();

            BokuGame.Load(this);
        }   // end of c'tor
        }   // end of ParticleSystemManager ClearAllEmitters()

        public void LoadContent(bool immediate)
        {
            if (effect2d == null)
            {
                effect2d = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Particle2D");
                effectCache2d.Load(effect2d);
            }

            if (effect3d == null)
            {
                effect3d = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Particle3D");
                ShaderGlobals.RegisterEffect("Particel3D", effect3d);
                effectCache3d.Load(effect3d);
            }

            SharedEmitterManager.LoadContent(immediate);

            BaseSpriteEmitter.LoadContent(immediate);

            ExplosionEmitter.LoadContent(immediate);
            FlowerEmitter.LoadContent(immediate);
            HeartEmitter.LoadContent(immediate);
            SmokeEmitter.LoadContent(immediate);
            StarEmitter.LoadContent(immediate);
            SteamEmitter.LoadContent(immediate);
            SwearEmitter.LoadContent(immediate);
            WreathEmitter.LoadContent(immediate);
            BeamExplosionEmitter.LoadContent(immediate);
            BeamSmokeEmitter.LoadContent(immediate);
            ScanExplosionEmitter.LoadContent(immediate);
            ScanSmokeEmitter.LoadContent(immediate);
            RoverScanExplosionEmitter.LoadContent(immediate);
            RoverScanSmokeEmitter.LoadContent(immediate);
            InspectExplosionEmitter.LoadContent(immediate);
            InspectSmokeEmitter.LoadContent(immediate);
            FanEmitter.LoadContent(immediate);
            InkEmitter.LoadContent(immediate);
        }   // end of ParticleSystemManager LoadContent()
Exemplo n.º 5
0
        protected float partial = 0.0f; // Number of particles that need to be emitted.
        public override void Update()
        {
            // See if we've died.
            if (Dying)
            {
                // We don't need to wait for any particles to
                // go away since the shared emitter owns them.
                Active = false;
                RemoveFromManager();
            }

            if (emitting)
            {
                float  dt  = Time.GameTimeFrameSeconds;
                Random rnd = BokuGame.bokuGame.rnd;

                if (LinearEmission)
                {
                    Vector3 deltaPosition = position - PreviousPosition;
                    float   dist          = deltaPosition.Length();

                    partial += dist * EmissionRate / Scale;
                }
                else
                {
                    partial += dt * EmissionRate;
                }

                // Emit as many particles as needed this
                // frame to keep up with the emission rate.
                SharedSmokeEmitter.SmokeParticle particle = new SharedSmokeEmitter.SmokeParticle();
                while (partial >= 1.0f)
                {
                    // Pick a random position somewhere along the path covered this frame.
                    Vector3 pos = position - (position - PreviousPosition) * (float)rnd.NextDouble();
                    if (PositionJitter > 0.0f)
                    {
                        pos += PositionJitter * new Vector3((float)rnd.NextDouble() - (float)rnd.NextDouble(), (float)rnd.NextDouble() - (float)rnd.NextDouble(), (float)rnd.NextDouble() - (float)rnd.NextDouble());
                    }
                    float lifetime = MinLifetime + (float)rnd.NextDouble() * (MaxLifetime - MinLifetime);

                    // Fill in the particle data.
                    particle.position     = pos;
                    particle.velocity     = velocity;
                    particle.acceleration = Vector3.Zero;
                    particle.color        = Color;
                    particle.startRadius  = StartRadius * Scale;
                    particle.endRadius    = EndRadius * Scale;
                    float rotationRate = MaxRotationRate * (float)(rnd.NextDouble() - rnd.NextDouble());
                    particle.rotationRate = rotationRate;
                    particle.lifetime     = lifetime;
                    particle.flash        = Vector3.Zero;

                    if ((usage & Use.Regular) != 0)
                    {
                        SharedEmitterManager.AddSmokeParticle(ref particle);
                    }

                    partial -= 1.0f;
                }
            }

            PreviousPosition = position;
        }   // end of Update()