Beispiel #1
0
        public int Fade(Particle particle, float ParticleLifeTime)
        {
            int fade = particle.Fade;

            if (ParticleFadeIn && ParticleFadeOut)
            {
                FadeDelay = (int)ParticleLifeTime / 2;
            }

            // Fade in
            if (ParticleFadeIn)
            {
                if (particle.TotalLifetime <= ParticleLifeTime - FadeDelay)
                {
                    fade = (int)(((particle.TotalLifetime) / (ParticleLifeTime - FadeDelay)) * particle.InitialOpacity);
                }
            }

            // Fade out
            if (ParticleFadeOut)
            {
                if (particle.TotalLifetime > FadeDelay)
                {
                    fade = particle.InitialOpacity - (int)(((particle.TotalLifetime - FadeDelay) / (ParticleLifeTime - FadeDelay)) * particle.InitialOpacity);
                }
            }

            return fade;
        }
Beispiel #2
0
 public void Scale(Particle particle, float ParticleLifeTime)
 {
     if (particle.TotalLifetime < ScaleStartTime)
     {
         particle.Scale = ScaleFrom;
     }
     else if (particle.TotalLifetime >= ScaleEndTime)
     {
         particle.Scale = ScaleTo;
     }
     else
     {
         particle.Scale = ScaleFrom + (((particle.TotalLifetime - ScaleStartTime) / (ScaleEndTime - ScaleStartTime)) * (ScaleTo - ScaleFrom));
     }
 }
Beispiel #3
0
        private void EmitParticle()
        {
            if (i > TextureList.Count - 1)
                i = 0;

            Particle particle = new Particle(TextureList[i],
                                             Position,
                                             (float)RandomizedDouble(ParticleSpeed),
                                             (float)RandomizedDouble(ParticleDirection),
                                             MathHelper.ToRadians((float)RandomizedDouble(ParticleRotation)),
                                             (float)RandomizedDouble(RotationSpeed),
                                             Opacity);
            ParticleList.Add(particle);
            EmittedNewParticle = true;
            LastEmittedParticle = particle;
            i++;
        }