コード例 #1
0
        public void InitializeParticleShockwave(DefaultTextureQuadTextureCoordinatesParticle particle)
        {
            particle.Lifetime = ShockwaveDuration;
            particle.Color    = ShockwaveColor;
            particle.Position = Emitter.PositionData.Position;
            particle.Normal   = new Vector3(0, 1, 0);
            particle.Size     = particle.StartSize = 1;
            particle.EndSize  = ShockwaveSize;

            particle.SetTextureCoordinates(_shockwaveTextureCoordinates, Texture.Width, Texture.Height);
        }
コード例 #2
0
        public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(0.5f, 1.0f);
            particle.Color    = ExplosionColor;
            particle.Position = Emitter.PositionData.Position;
            particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(175, 225);
            particle.Right    = -particle.Velocity;
            particle.Width    = ExplosionParticleSize;
            particle.Height   = ExplosionParticleSize * _textureAspectRatio;

            // Set the spark particle's texture coordinates
            particle.SetTextureCoordinates(_sparkTextureCoordinates, Texture.Width, Texture.Height);
        }
コード例 #3
0
        public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(0.3f, 0.5f);
            particle.Color    = ExplosionColor;
            particle.Position = Emitter.PositionData.Position;
            particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(100, 150);
            particle.Right    = -particle.Velocity;

            // Specify the particle's width-to-height ratio as 8:1 so it looks better
            particle.Width = 8; particle.Height = 1;

            // Calculate and set what the particle's EndWidth and EndHeight should be (2 times the start size)
            particle.ScaleToWidth(ExplosionParticleSize * 2);
            particle.EndWidth  = particle.Width;
            particle.EndHeight = particle.Height;

            // Calculate and set what the particle's StartWidth and StartHeight should be
            particle.ScaleToWidth(ExplosionParticleSize);
            particle.StartWidth  = particle.Width;
            particle.StartHeight = particle.Height;

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

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

            case 1: textureCoordinates = _smokeTrail2TextureCoordinates; break;

            case 2: textureCoordinates = _smokeTrail3TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates, Texture.Width, Texture.Height);
        }
コード例 #4
0
		public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle)
		{
			particle.Lifetime = RandomNumber.Between(0.5f, 1.0f);
			particle.Color = ExplosionColor;
			particle.Position = Emitter.PositionData.Position;
			particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(175, 225);
			particle.Right = -particle.Velocity;	// Orient the particle according to it's velocity.
			particle.Width = ExplosionParticleSize;
			particle.Height = ExplosionParticleSize * _textureAspectRatio;

			// Set the spark particle's texture coordinates
			particle.SetTextureCoordinates(_sparkTextureCoordinates, Texture.Width, Texture.Height);
		}
コード例 #5
0
ファイル: PickupBurst.cs プロジェクト: kozupi/--
		public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle)
		{
			particle.Lifetime = RandomNumber.Between(0.3f, 0.5f);
			particle.Color = Color.HotPink;
			particle.Position = Emitter.PositionData.Position;
			particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(50, 100);
			particle.Right = -particle.Velocity;	// Orient the particle according to it's velocity.

			// Specify the particle's width-to-height ratio as 8:1 so it looks better
			particle.Width = 10; particle.Height = 1;

			// Calculate and set what the particle's EndWidth and EndHeight should be (2 times the start size)
			particle.ScaleToWidth(ExplosionParticleSize * 2);
			particle.EndWidth = particle.Width;
			particle.EndHeight = particle.Height;

			// Calculate and set what the particle's StartWidth and StartHeight should be
			particle.ScaleToWidth(ExplosionParticleSize);
			particle.StartWidth = particle.Width;
			particle.StartHeight = particle.Height;

			// Randomly pick which texture coordinates to use for this particle
			/*Rectangle textureCoordinates;
			switch (RandomNumber.Next(0, 3))
			{
				default:
				case 0: textureCoordinates = _smokeTrail1TextureCoordinates; break;
				case 1: textureCoordinates = _smokeTrail2TextureCoordinates; break;
				case 2: textureCoordinates = _smokeTrail3TextureCoordinates; break;
			}
			
			particle.SetTextureCoordinates(textureCoordinates, Texture.Width, Texture.Height);*/
		}
コード例 #6
0
		//===========================================================
		// Other Particle System Functions
		//===========================================================

		/// <summary>
		/// Start the explosion.
		/// </summary>
		public void Explode()
		{
			// Create the particle that we will model other particles added to the particle system after (i.e. a Shockwave particle)
			DefaultTextureQuadTextureCoordinatesParticle particle = new DefaultTextureQuadTextureCoordinatesParticle();
			this.InitializeParticleShockwave(particle);

			// If a shockwave should be created, set the model-particle to the proper orientation and add a copy of the model-particle to the particle system.
			if (ShockwaveXAxisEnabled)
			{
				particle.Normal = new Vector3(1, 0, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveYAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveZAxisEnabled)
			{
				particle.Normal = new Vector3(0, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveXYAxisEnabled)
			{
				particle.Normal = new Vector3(1, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveXZAxisEnabled)
			{
				particle.Normal = new Vector3(1, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveYZAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveXYNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(-1, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveXZNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(-1, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveYZNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, -1);
				this.AddParticle(particle);
			}
		}
コード例 #7
0
		//===========================================================
		// Particle Update Functions
		//===========================================================
		protected void UpdateParticleTransparencyToBeMoreTransparent(DefaultTextureQuadTextureCoordinatesParticle particle, float elapsedTimeInSeconds)
		{
			particle.Color.A = (byte)(particle.Color.A * this.ShockwaveTransparency);
		}
コード例 #8
0
		public void InitializeParticleShockwave(DefaultTextureQuadTextureCoordinatesParticle particle)
		{
			particle.Lifetime = ShockwaveDuration;
			particle.Color = ShockwaveColor;
			particle.Position = Emitter.PositionData.Position;
			particle.Normal = new Vector3(0, 1, 0);
			particle.Size = particle.StartSize = 1;
			particle.EndSize = ShockwaveSize;

			particle.SetTextureCoordinates(_shockwaveTextureCoordinates, Texture.Width, Texture.Height);
		}
コード例 #9
0
        //===========================================================
        // Other Particle System Functions
        //===========================================================

        /// <summary>
        /// Start the explosion.
        /// </summary>
        public void Explode()
        {
            // Create the particle that we will model other particles added to the particle system after (i.e. a Shockwave particle)
            DefaultTextureQuadTextureCoordinatesParticle particle = new DefaultTextureQuadTextureCoordinatesParticle();

            this.InitializeParticleShockwave(particle);

            // If a shockwave should be created, set the model-particle to the proper orientation and add a copy of the model-particle to the particle system.
            if (ShockwaveXAxisEnabled)
            {
                particle.Normal = new Vector3(1, 0, 0);
                this.AddParticle(particle);
            }

            if (ShockwaveYAxisEnabled)
            {
                particle.Normal = new Vector3(0, 1, 0);
                this.AddParticle(particle);
            }

            if (ShockwaveZAxisEnabled)
            {
                particle.Normal = new Vector3(0, 0, 1);
                this.AddParticle(particle);
            }

            if (ShockwaveXYAxisEnabled)
            {
                particle.Normal = new Vector3(1, 1, 0);
                this.AddParticle(particle);
            }

            if (ShockwaveXZAxisEnabled)
            {
                particle.Normal = new Vector3(1, 0, 1);
                this.AddParticle(particle);
            }

            if (ShockwaveYZAxisEnabled)
            {
                particle.Normal = new Vector3(0, 1, 1);
                this.AddParticle(particle);
            }

            if (ShockwaveXYNegativeAxisEnabled)
            {
                particle.Normal = new Vector3(-1, 1, 0);
                this.AddParticle(particle);
            }

            if (ShockwaveXZNegativeAxisEnabled)
            {
                particle.Normal = new Vector3(-1, 0, 1);
                this.AddParticle(particle);
            }

            if (ShockwaveYZNegativeAxisEnabled)
            {
                particle.Normal = new Vector3(0, 1, -1);
                this.AddParticle(particle);
            }
        }
コード例 #10
0
 //===========================================================
 // Particle Update Functions
 //===========================================================
 protected void UpdateParticleTransparencyToBeMoreTransparent(DefaultTextureQuadTextureCoordinatesParticle particle, float elapsedTimeInSeconds)
 {
     particle.Color.A = (byte)(particle.Color.A * this.ShockwaveTransparency);
 }
コード例 #11
0
		public void InitializeParticleShockwave(DefaultTextureQuadTextureCoordinatesParticle particle)
		{
			particle.Lifetime = ShockwaveDuration;
			particle.Color = ShockwaveColor;
			particle.Position = Emitter.PositionData.Position;
			particle.Normal = new Vector3(0, 1, 0);
			particle.Size = particle.StartSize = 1;
			particle.EndSize = ShockwaveSize;

			particle.SetTextureCoordinates(_shockwaveTextureCoordinates, Texture.Width, Texture.Height);

			// If a shockwave should be created, set the model-particle to the proper orientation and add a copy of the model-particle to the particle system.
			if (ShockwaveXAxisEnabled)
			{
				particle.Normal = new Vector3(1, 0, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveYAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveZAxisEnabled)
			{
				particle.Normal = new Vector3(0, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveXYAxisEnabled)
			{
				particle.Normal = new Vector3(1, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveXZAxisEnabled)
			{
				particle.Normal = new Vector3(1, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveYZAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveXYNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(-1, 1, 0);
				this.AddParticle(particle);
			}

			if (ShockwaveXZNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(-1, 0, 1);
				this.AddParticle(particle);
			}

			if (ShockwaveYZNegativeAxisEnabled)
			{
				particle.Normal = new Vector3(0, 1, -1);
				this.AddParticle(particle);
			}
		}
コード例 #12
0
        public void InitializeParticleWithTextureCoordinates(DefaultTextureQuadTextureCoordinatesParticle 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, Texture.Width, Texture.Height);
        }
コード例 #13
0
        //===========================================================
        // Particle Update Functions
        //===========================================================
        protected void BounceOffFloor(DefaultTextureQuadTextureCoordinatesParticle cParticle, float fElapsedTimeInSeconds)
        {
            // If the Particle has hit the floor and is still travelling downwards
            if (cParticle.Position.Y <= 0 && cParticle.Velocity.Y < 0)
            {
                // Make the Particle Bounce upwards
                cParticle.Velocity.Y *= -mfBounciness;

                // Reduce the Particles X and Z speed
                cParticle.Velocity.X *= 0.8f;
                cParticle.Velocity.Z *= 0.8f;

                // Reduce the Particles Rotation speed
                cParticle.RotationalVelocity *= 0.8f;
            }
        }