/// <summary> /// Example of how to create a Particle Initialization Function /// </summary> /// <param name="cParticle">The Particle to be Initialized</param> /// public void InitialiseIndicatorParticle(DefaultSpriteParticle cParticle) { InitializeParticleUsingInitialProperties(cParticle); cParticle.Lifetime = 0.0f; cParticle.RotationalVelocity = 5f; cParticle.Color = Color.White; }
public override void InitializeParticleProperties(DefaultSpriteParticle cParticle) { cParticle.Lifetime = DPSFHelper.RandomNumberBetween(.5f, 1); cParticle.Position = Emitter.PositionData.Position; float randomVelocity = DPSFHelper.RandomNumberBetween(-200, 200); currentRotation += (float)Math.PI / 20; Vector2 rotatedRandomVector = TankGame.rotateVector(new Vector2(randomVelocity, randomVelocity), currentRotation); cParticle.Velocity = new Vector3(rotatedRandomVector.X, rotatedRandomVector.Y, 0); cParticle.Width = DPSFHelper.RandomNumberBetween(2, 6); cParticle.Height = DPSFHelper.RandomNumberBetween(2, 12); cParticle.Rotation = currentRotation; //Vector3 sVelocityMin = new Vector3(-100, 25, -100); //Vector3 sVelocityMax = new Vector3(100, 50, 100); //cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); cParticle.StartColor = startColor; cParticle.EndColor = endColor; }
/// <summary> /// Example of how to create a Particle Initialization Function /// </summary> /// <param name="cParticle">The Particle to be Initialized</param> public void InitializeParticleProperties(DefaultSpriteParticle cParticle) { //----------------------------------------------------------- // TODO: Initialize all of the Particle's properties here. // If you plan on simply using the default InitializeParticleUsingInitialProperties // Particle Initialization Function (see the LoadParticleSystem() function above), // then you may delete this function all together. //----------------------------------------------------------- // Set the Particle's Lifetime (how long it should exist for) cParticle.Lifetime = 2.0f; // Set the Particle's initial Position to be wherever the Emitter is cParticle.Position = Emitter.PositionData.Position; // Set the Particle's Velocity Vector3 sVelocityMin = new Vector3(-200, -200, 0); Vector3 sVelocityMax = new Vector3(200, -400, 0); cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); // Adjust the Particle's Velocity direction according to the Emitter's Orientation cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); // Give the Particle a random Size // Since we have Size Lerp enabled we must also set the Start and End Size cParticle.Width = cParticle.StartWidth = cParticle.EndWidth = cParticle.Height = cParticle.StartHeight = cParticle.EndHeight = RandomNumber.Next((int)mfSizeMin, (int)mfSizeMax); // Give the Particle a random Color // Since we have Color Lerp enabled we must also set the Start and End Color cParticle.Color = cParticle.StartColor = cParticle.EndColor = DPSFHelper.RandomColor(); }
public void InitializeParticleDot(DefaultSpriteParticle cParticle) { cParticle.Lifetime = 1.0f; cParticle.Position = Emitter.PositionData.Position; cParticle.Size = 10.0f; cParticle.Color = Color.White; cParticle.Velocity = Vector3.Zero; cParticle.Acceleration = Vector3.Zero; }
public override void InitializeParticleProperties(DefaultSpriteParticle cParticle) { cParticle.Lifetime = DPSFHelper.RandomNumberBetween(1, 2); cParticle.Position = Emitter.PositionData.Position; cParticle.StartSize = 40; cParticle.EndSize = 10; cParticle.StartColor = Color.Yellow; cParticle.EndColor = Color.DarkRed; }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void UpdateParticlePositionBySphereLerp(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { cParticle.Position = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), cParticle.NormalizedElapsedTime * radius); cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); // Adjust the Particle's Velocity direction according to the Emitter's Orientation //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; }
public override void InitializeParticleProperties(DefaultSpriteParticle cParticle) { cParticle.Lifetime = DPSFHelper.RandomNumberBetween(.1f, lifeTime / 2); cParticle.Position = Emitter.PositionData.Position; currentRotation += (float)Math.PI / 10; Vector2 rotatedRandomVector = TankGame.rotateVector(originalVector, currentRotation); cParticle.Velocity = new Vector3(rotatedRandomVector.X * 60, rotatedRandomVector.Y * 60, 0); cParticle.Size = DPSFHelper.RandomNumberBetween(1, 4); cParticle.Rotation = currentRotation; cParticle.StartColor = Color.Yellow; cParticle.EndColor = Color.Red; cParticle.Friction = DPSFHelper.RandomNumberBetween(50, 200); }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void LerpParticleDistance(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; if (cParticle.Lifetime != 0) { cParticle.Position.X = 0; cParticle.Position.Y = (3 - extradist) + 12 * (1.0f - cParticle.NormalizedElapsedTime); cParticle.Position.Z = 0; cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; } else { cParticle.Position.X = 0; cParticle.Position.Y = 3; cParticle.Position.Z = 0; cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; } }
/// <summary> /// Example of how to create a Particle Initialization Function /// </summary> /// <param name="cParticle">The Particle to be Initialized</param> public void InitializeParticleProperties(DefaultSpriteParticle cParticle) { //----------------------------------------------------------- // TODO: Initialize all of the Particle's properties here. // If you plan on simply using the default InitializeParticleUsingInitialProperties // Particle Initialization Function (see the LoadParticleSystem() function above), // then you may delete this function all together. //----------------------------------------------------------- // Set the Particle's Lifetime (how long it should exist for) cParticle.Lifetime = lifeTime; // Set the Particle's initial Position to be wherever the Emitter is cParticle.Position = Emitter.PositionData.Position + offset + Position; // Set the Particle's Velocity Vector3 sVelocityMin = new Vector3(0, -speedMin * Velocity, 0); Vector3 sVelocityMax = new Vector3(0, -speedMax * Velocity, 0); cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); // Adjust the Particle's Velocity direction according to the Emitter's Orientation cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); // Give the Particle a random Size // Since we have Size Lerp enabled we must also set the Start and End Size cParticle.Width = cParticle.StartWidth = cParticle.Height = sizeMax * Size; cParticle.EndWidth = cParticle.EndHeight = sizeMin * Size; // Give the Particle a random Color // Since we have Color Lerp enabled we must also set the Start and End Color cParticle.Color = cParticle.StartColor = cParticle.EndColor = color; }
/// <summary> /// Example of how to create a Particle Initialization Function /// </summary> /// <param name="cParticle">The Particle to be Initialized</param> public void InitializeParticleProperties(DefaultSpriteParticle cParticle) { //----------------------------------------------------------- // TODO: Initialize all of the Particle's properties here. // If you plan on simply using the default InitializeParticleUsingInitialProperties // Particle Initialization Function (see the LoadParticleSystem() function above), // then you may delete this function all together. //----------------------------------------------------------- // Set the Particle's Lifetime (how long it should exist for) cParticle.Lifetime =0.05f;//2.0f; // Set the Particle's initial Position to be wherever the Emitter is cParticle.Position = Emitter.PositionData.Position; // Set the Particle's Velocity Vector3 sVelocityMin = new Vector3(-8, -8, 0); Vector3 sVelocityMax = new Vector3(8, 8, 0); cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); // Adjust the Particle's Velocity direction according to the Emitter's Orientation cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); UpdateParticleTransparencyToFadeOutUsingLerp(cParticle, 0.1f); // Give the Particle a random Size // Since we have Size Lerp enabled we must also set the Start and End Size //cParticle.Width = cParticle.StartWidth = cParticle.EndWidth = // cParticle.Height = cParticle.StartHeight = cParticle.EndHeight = RandomNumber.Next((int)mfSizeMin, (int)mfSizeMax); // Give the Particle a random Color // Since we have Color Lerp enabled we must also set the Start and End Color cParticle.Color = cParticle.StartColor = Color.Blue; cParticle.EndColor = Color.Crimson; }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> public void UpdateParticle(DefaultSpriteParticle cParticle, Vector2 velocity, float rotation) { cParticle.Velocity += new Vector3(velocity.X, velocity.Y, 0); // Place code to update the Particle here /*if (count < 2) { cParticle.Velocity += new Vector3(velocity.X, velocity.Y, 0); count++; } else if (count < 3) { cParticle.Velocity += new Vector3((4), (4), 0); count++; } else if (count < 4) { cParticle.Velocity += new Vector3(( - 4), (- 4), 0); count++; } else { count = 0; }*/ // Adjust the Particle's Velocity direction according to the Emitter's Orientation cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); //Console.WriteLine(cParticle.Velocity); cParticle.Position = Emitter.PositionData.Position; cParticle.Position += cParticle.Velocity; }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void LerpParticleDistance(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; if (cParticle.Lifetime != 0) { cParticle.Position.X = 0; cParticle.Position.Y = (3-extradist) + 12 * (1.0f - cParticle.NormalizedElapsedTime); cParticle.Position.Z = 0; cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; } else { cParticle.Position.X = 0; cParticle.Position.Y = 3; cParticle.Position.Z = 0; cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; } }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> public void UpdateParticle(DefaultSpriteParticle cParticle, Vector2 velocity) { // Place code to update the Particle here cParticle.Velocity += new Vector3(velocity.X, velocity.Y, 0); cParticle.Position += cParticle.Velocity; }
public void InitialiseParticleProperties(DefaultSpriteParticle cParticle) { //----------------------------------------------------------- // TODO: Initialize all of the Particle's properties here. // If you plan on simply using the default InitializeParticleUsingInitialProperties // Particle Initialization Function (see the LoadParticleSystem() function above), // then you may delete this function all together. //----------------------------------------------------------- //Quaternion cBackup = Emitter.OrientationData.Orientation; //Emitter.OrientationData.Orientation = Quaternion.Identity; InitializeParticleUsingInitialProperties(cParticle); //Emitter.OrientationData.Orientation = cBackup; // Set the Particle's Lifetime (how long it should exist for) cParticle.Lifetime = normLifetime+overrun; // Set the Particle's initial Position to be wherever the Emitter is cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); //cParticle.Position += Emitter.PositionData.Position; // Set the Particle's Velocity //Vector3 sVelocityMin = new Vector3(-50, 50, -50); //Vector3 sVelocityMax = new Vector3(50, 100, 50); //cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); // Adjust the Particle's Velocity direction according to the Emitter's Orientation //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); // Give the Particle a random Size // Since we have Size Lerp enabled we must also set the Start and End Size //cParticle.Width = cParticle.StartWidth = cParticle.EndWidth = // cParticle.Height = cParticle.StartHeight = cParticle.EndHeight = RandomNumber.Next((int)mfSizeMin, (int)mfSizeMax); // Give the Particle a random Color // Since we have Color Lerp enabled we must also set the Start and End Color //cParticle.Color = cParticle.StartColor = cParticle.EndColor = DPSFHelper.RandomColor(); }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void UpdateParticleFunctionExample(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void UpdateParticlePosition(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { cParticle.Position = Emitter.PositionData.Position; // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; }
//=========================================================== // Particle Update Functions //=========================================================== //----------------------------------------------------------- // TODO: Place your Particle Update functions here, using the // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float)) //----------------------------------------------------------- /// <summary> /// Example of how to create a Particle Event Function /// </summary> /// <param name="cParticle">The Particle to update</param> /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param> protected void UpdateParticlePositionBySphereLerp(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds) { cParticle.Position = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), cParticle.NormalizedElapsedTime*radius); cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation); // Adjust the Particle's Velocity direction according to the Emitter's Orientation //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); cParticle.Position += Emitter.PositionData.Position; // Place code to update the Particle here // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds; }