/// <summary> /// Deep copy all of the Particle properties /// </summary> /// <param name="ParticleToCopy">The Particle to Copy the properties from</param> public override void CopyFrom(DPSFParticle ParticleToCopy) { // Cast the Particle to the type it really is DefaultSpriteTextureCoordinatesParticle cParticleToCopy = (DefaultSpriteTextureCoordinatesParticle)ParticleToCopy; base.CopyFrom(cParticleToCopy); this.TextureCoordinates = cParticleToCopy.TextureCoordinates; }
//=========================================================== // Draw Sprite and Overridden Particle System Functions //=========================================================== /// <summary> /// Function to draw a Sprite Particle. This function should be used to draw the given /// Particle with the provided SpriteBatch. /// </summary> /// <param name="Particle">The Particle Sprite to Draw</param> /// <param name="cSpriteBatch">The SpriteBatch to use to doing the Drawing</param> protected override void DrawSprite(DPSFParticle Particle, SpriteBatch cSpriteBatch) { // Cast the Particle to the type it really is DefaultSpriteTextureCoordinatesParticle cParticle = (DefaultSpriteTextureCoordinatesParticle)Particle; // Get the Position and Dimensions of the Particle in 2D space Rectangle sDestination = new Rectangle((int)cParticle.Position.X, (int)cParticle.Position.Y, (int)cParticle.Width, (int)cParticle.Height); // Get the Depth (Z-Buffer value) of the Particle clamped in the range 0.0 - 1.0 (0.0 = front, 1.0 = back) float fNormalizedDepth = MathHelper.Clamp(cParticle.Position.Z, 0.0f, 1.0f); // Get the Position and Dimensions from the Texture to use for this Sprite Rectangle sSourceFromTexture = cParticle.TextureCoordinates; // Make the Sprite rotate about its center Vector2 sOrigin = new Vector2(sSourceFromTexture.Width / 2, sSourceFromTexture.Height / 2); // Draw the Sprite cSpriteBatch.Draw(Texture, sDestination, sSourceFromTexture, cParticle.Color, cParticle.Rotation, sOrigin, cParticle.FlipMode, fNormalizedDepth); }