Esempio n. 1
0
        public void AddExplosion(Vector2 position)
        {
            ExplosionParticleSystem explosion = new ExplosionParticleSystem(Game, 1);

            explosion.AddParticles(position);
            explosions.Add(explosion);
        }
Esempio n. 2
0
        // this function is called when we want to demo the explosion effect. it
        // updates the timeTillExplosion timer, and starts another explosion effect
        // when the timer reaches zero.
        private void UpdateExplosions(float dt)
        {
            if (!startExplosionEffect)
            {
                return;
            }

            timeTillExplosion -= dt;
            if (timeTillExplosion < 0)
            {
                Vector2 where = Vector2.Zero;

                // the overall explosion effect is actually comprised of two particle
                // systems: the fiery bit, and the smoke behind it. add particles to
                // both of those systems.
                explosion.AddParticles(where);
                smoke.AddParticles(where);

                // reset the timer.
                timeTillExplosion = TimeBetweenExplosions;
            }

            // Update duration
            timeExplosionEffect += dt;
            if (timeExplosionEffect > MAX_EXPLOSION_EFFECT_TIME)
            {
                startExplosionEffect = false;
                timeExplosionEffect  = 0.0f;
            }
        }