Exemple #1
0
 public void Update(float elapsed)
 {
     if (_isPaused == false)
     {
         float lerpLife = currentLife / maxLife;
         // update the particles with the emitter properties
         for (int i = 0; i < particleTypes.Count; i++)
         {
             if (particleTypes[i].Parent != this)
             {
                 particleTypes[i].Parent = this;
             }
             float _emissionAngle   = Particle.GetLerpValue(emissionAngle.Values, lerpLife);
             float _emissionRange   = Particle.GetLerpValue(emissionRange.Values, lerpLife);
             float _opacityModifier = Particle.GetLerpValue(globalOpacityModifier.Values, lerpLife);
             particleTypes[i].Update(elapsed, lerpLife, shape, _opacityModifier, _emissionAngle, _emissionRange);
         }
         currentLife += 1.0f;
         if (currentLife > maxLife)
         {
             // reset the life
             currentLife = 0.0f;
             // increment the loop counter
             _loopCounter++;
             // check if we need to stop
             if (_parent.LoopMax > 0 && _loopCounter >= _parent.LoopMax)
             {
                 _isStopped = true;
                 for (int i = 0; i < particleTypes.Count; i++)
                 {
                     particleTypes[i].OnEmissionFinished();
                 }
             }
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Get the linear interpolation value with an added random variation
 /// </summary>
 /// <param name="values">The key values</param>
 /// <param name="variations">The key variation values</param>
 /// <param name="lerpLife">The life, between 0 and 1</param>
 /// <returns></returns>
 public static float GetLerpValueWithVariation(List <Vector2> values, List <Vector2> variations, float lerpLife)
 {
     return(GetLerpValue(values, lerpLife) + Particle.GetRandomVariationValue(Particle.GetLerpValue(variations, lerpLife)));
 }