Пример #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;
        }
Пример #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));
     }
 }
Пример #3
0
        private void EmitParticle()
        {
            if (i > TextureList.Count - 1) i = 0;

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