Example #1
0
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime = 0.2f;
            particle.Color    = ExplosionColor;
            particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-15, 15), RandomNumber.Next(-15, 15), RandomNumber.Next(-15, 15));
            particle.Size     = particle.StartSize = 1;
            particle.EndSize  = ExplosionParticleSize;

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;

            switch (RandomNumber.Next(0, 4))
            {
            default:
            case 0: textureCoordinates = _flash1TextureCoordinates; break;

            case 1: textureCoordinates = _flash2TextureCoordinates; break;

            case 2: textureCoordinates = _flash3TextureCoordinates; break;

            case 3: textureCoordinates = _flash4TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime      = RandomNumber.Between(0.3f, 0.7f);
            particle.Color         = particle.StartColor = ExplosionColor;
            particle.EndColor      = Color.Black;
            particle.Position      = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity      = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(1, 50);
            particle.ExternalForce = new Vector3(0, 80, 0);  // We want the smoke to rise
            particle.Size          = particle.StartSize = 1; // Have the particles start small and grow
            particle.EndSize       = ExplosionParticleSize;

            // Give the particle a random initial orientation and random rotation velocity (only need to Roll the particle since it will always face the camera)
            particle.Rotation           = RandomNumber.Between(0, MathHelper.TwoPi);
            particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;

            switch (RandomNumber.Next(0, 4))
            {
            default:
            case 0: textureCoordinates = _flameSmoke1TextureCoordinates; break;

            case 1: textureCoordinates = _flameSmoke2TextureCoordinates; break;

            case 2: textureCoordinates = _flameSmoke3TextureCoordinates; break;

            case 3: textureCoordinates = _flameSmoke4TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);
        }
Example #3
0
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime      = RandomNumber.Between(0.5f, 1.0f);
            particle.Color         = ExplosionColor;
            particle.Position      = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity      = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(30, 50);
            particle.ExternalForce = new Vector3(0, 20, 0);
            particle.Size          = ExplosionParticleSize;

            particle.SetTextureCoordinates(_roundSparkTextureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime = 0.2f;
            particle.Color = ExplosionColor;
            particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-15, 15), RandomNumber.Next(-15, 15), RandomNumber.Next(-15, 15));
            particle.Size = particle.StartSize = 1;
            particle.EndSize = ExplosionParticleSize;

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;
            switch (RandomNumber.Next(0, 4))
            {
                default:
                case 0: textureCoordinates = _flash1TextureCoordinates; break;
                case 1: textureCoordinates = _flash2TextureCoordinates; break;
                case 2: textureCoordinates = _flash3TextureCoordinates; break;
                case 3: textureCoordinates = _flash4TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(1.2f, 1.7f);
            particle.Color = particle.StartColor = ExplosionColor;
            particle.EndColor = Color.DarkGray;
            particle.Position = Emitter.PositionData.Position;
            particle.ExternalForce = new Vector3(0, -80, 0);
            particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);
            particle.Velocity = DPSFHelper.RandomNormalizedVector();    // Calculate the direction the particle will travel in

            // We want the debris to travel upwards more often than downward, so if it's travelling downward switch it to travel upward 50% of the time
            if (particle.Velocity.Y < 0 && RandomNumber.Next(0, 2) == 0)
                particle.Velocity.Y *= -1;

            // Fire some particles towards the camera (but not directly at it) for a more dramatic effect
            if (RandomNumber.Between(0, 5) == 0)
            {
                // Calculate a point somewhere around the camera
                int distance = 10;
                Vector3 somewhereAroundTheCamera = new Vector3(CameraPosition.X + RandomNumber.Next(-distance, distance),
                                                               CameraPosition.Y + RandomNumber.Next(-distance, distance),
                                                               CameraPosition.Z + RandomNumber.Next(-distance, distance));

                // Direct the Particle towards the spot around the camera
                particle.Velocity = somewhereAroundTheCamera - particle.Position;
                particle.Velocity.Normalize();
            }

            // Set the Particle's Speed
            particle.Velocity *= RandomNumber.Next(100, 150);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;
            switch (RandomNumber.Next(0, 9))
            {
                default:
                case 0: textureCoordinates = _debris1TextureCoordinates; break;
                case 1: textureCoordinates = _debris2TextureCoordinates; break;
                case 2: textureCoordinates = _debris3TextureCoordinates; break;
                case 3: textureCoordinates = _debris4TextureCoordinates; break;
                case 4: textureCoordinates = _debris5TextureCoordinates; break;
                case 5: textureCoordinates = _debris6TextureCoordinates; break;
                case 6: textureCoordinates = _debris7TextureCoordinates; break;
                case 7: textureCoordinates = _debris8TextureCoordinates; break;
                case 8: textureCoordinates = _debris9TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);

            // Set the Width to Height ratio so the image isn't skewed when we scale it
            particle.Width = textureCoordinates.Width;
            particle.Height = textureCoordinates.Height;

            // Set the particle to the specified size, give or take 25%
            particle.ScaleToWidth(ExplosionParticleSize * RandomNumber.Between(0.75f, 1.25f));
        }
        public void InitializeParticleWithTextureCoordinates(DefaultSprite3DBillboardTextureCoordinatesParticle cParticle)
        {
            // Initialize the particle using the InitialProperties specified above
            InitializeParticleUsingInitialProperties(cParticle);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle sTextureCoordinates;
            switch (RandomNumber.Next(0, 4))
            {
                default:
                case 0: sTextureCoordinates = msCloudTextureCoordinates; break;
                case 1: sTextureCoordinates = msSparkTextureCoordinates; break;
                case 2: sTextureCoordinates = msRockTextureCoordinates; break;
                case 3: sTextureCoordinates = msRingTextureCoordinates; break;
            }

            // Set the Particle's Texture Coordinates
            cParticle.SetTextureCoordinates(sTextureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(0.5f, 1.0f);
            particle.Color = ExplosionColor;
            particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(30, 50);
            particle.ExternalForce = new Vector3(0, 20, 0);
            particle.Size = ExplosionParticleSize;

            particle.SetTextureCoordinates(_roundSparkTextureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(0.3f, 0.7f);
            particle.Color = particle.StartColor = ExplosionColor;
            particle.EndColor = Color.Black;
            particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(1, 50);
            particle.ExternalForce = new Vector3(0, 80, 0); // We want the smoke to rise
            particle.Size = particle.StartSize = 1;         // Have the particles start small and grow
            particle.EndSize = ExplosionParticleSize;

            // Give the particle a random initial orientation and random rotation velocity (only need to Roll the particle since it will always face the camera)
            particle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);
            particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;
            switch (RandomNumber.Next(0, 4))
            {
                default:
                case 0: textureCoordinates = _flameSmoke1TextureCoordinates; break;
                case 1: textureCoordinates = _flameSmoke2TextureCoordinates; break;
                case 2: textureCoordinates = _flameSmoke3TextureCoordinates; break;
                case 3: textureCoordinates = _flameSmoke4TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime           = RandomNumber.Between(1.2f, 1.7f);
            particle.Color              = particle.StartColor = ExplosionColor;
            particle.EndColor           = Color.DarkGray;
            particle.Position           = Emitter.PositionData.Position;
            particle.ExternalForce      = new Vector3(0, -80, 0);
            particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);
            particle.Velocity           = DPSFHelper.RandomNormalizedVector(); // Calculate the direction the particle will travel in

            // We want the debris to travel upwards more often than downward, so if it's travelling downward switch it to travel upward 50% of the time
            if (particle.Velocity.Y < 0 && RandomNumber.Next(0, 2) == 0)
            {
                particle.Velocity.Y *= -1;
            }

            // Fire some particles towards the camera (but not directly at it) for a more dramatic effect
            if (RandomNumber.Between(0, 5) == 0)
            {
                // Calculate a point somewhere around the camera
                int     distance = 10;
                Vector3 somewhereAroundTheCamera = new Vector3(CameraPosition.X + RandomNumber.Next(-distance, distance),
                                                               CameraPosition.Y + RandomNumber.Next(-distance, distance),
                                                               CameraPosition.Z + RandomNumber.Next(-distance, distance));

                // Direct the Particle towards the spot around the camera
                particle.Velocity = somewhereAroundTheCamera - particle.Position;
                particle.Velocity.Normalize();
            }

            // Set the Particle's Speed
            particle.Velocity *= RandomNumber.Next(100, 150);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;

            switch (RandomNumber.Next(0, 9))
            {
            default:
            case 0: textureCoordinates = _debris1TextureCoordinates; break;

            case 1: textureCoordinates = _debris2TextureCoordinates; break;

            case 2: textureCoordinates = _debris3TextureCoordinates; break;

            case 3: textureCoordinates = _debris4TextureCoordinates; break;

            case 4: textureCoordinates = _debris5TextureCoordinates; break;

            case 5: textureCoordinates = _debris6TextureCoordinates; break;

            case 6: textureCoordinates = _debris7TextureCoordinates; break;

            case 7: textureCoordinates = _debris8TextureCoordinates; break;

            case 8: textureCoordinates = _debris9TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);

            // Set the Width to Height ratio so the image isn't skewed when we scale it
            particle.Width  = textureCoordinates.Width;
            particle.Height = textureCoordinates.Height;

            // Set the particle to the specified size, give or take 25%
            particle.ScaleToWidth(ExplosionParticleSize * RandomNumber.Between(0.75f, 1.25f));
        }