public void Update() { var dt = (Type.UseActualDeltaTime ? Engine.RawDeltaTime : Engine.DeltaTime); var ease = Life / StartLife; //Life Life -= dt; if (Life <= 0) { Active = false; return; } //Color switch if (Type.ColorMode == ParticleType.ColorModes.Fade) { Color = Color.Lerp(Type.Color2, Type.Color, ease); } else if (Type.ColorMode == ParticleType.ColorModes.Blink) { Color = Calc.BetweenInterval(Life, .1f) ? Type.Color : Type.Color2; } //Speed Position += Speed * dt; Speed += Type.Acceleration * dt; Speed = Calc.Approach(Speed, Vector2.Zero, Type.Friction * dt); if (Type.SpeedMultiplier != 1) { Speed *= (float)Math.Pow(Type.SpeedMultiplier, dt); } //Scale Out if (Type.ScaleOut) { Size = StartSize * Ease.CubeOut(ease); } }
public void Update(float?delta = null) { var dt = 0f; if (delta.HasValue) { dt = delta.Value; } else { dt = (Type.UseActualDeltaTime ? Engine.RawDeltaTime : Engine.DeltaTime); } var ease = Life / StartLife; //Life Life -= dt; if (Life <= 0) { Active = false; return; } //Spin if (Type.RotationMode == ParticleType.RotationModes.SameAsDirection) { if (Speed != Vector2.Zero) { Rotation = Speed.Angle(); } } else { Rotation += Spin * dt; } //Fade float alpha; if (Type.FadeMode == ParticleType.FadeModes.Linear) { alpha = ease; } else if (Type.FadeMode == ParticleType.FadeModes.Late) { alpha = Math.Min(1f, ease / .25f); } else if (Type.FadeMode == ParticleType.FadeModes.InAndOut) { if (ease > .75f) { alpha = 1 - ((ease - .75f) / .25f); } else if (ease < .25f) { alpha = ease / .25f; } else { alpha = 1f; } } else { alpha = 1f; } //Color switch with alpha if (alpha == 0) { Color = Color.Transparent; } else { if (Type.ColorMode == ParticleType.ColorModes.Static) { Color = StartColor; } else if (Type.ColorMode == ParticleType.ColorModes.Fade) { Color = Color.Lerp(Type.Color2, StartColor, ease); } else if (Type.ColorMode == ParticleType.ColorModes.Blink) { Color = (Calc.BetweenInterval(Life, .1f) ? StartColor : Type.Color2); } else if (Type.ColorMode == ParticleType.ColorModes.Choose) { Color = StartColor; } if (alpha < 1f) { Color *= alpha; } } //Speed Position += Speed * dt; Speed += Type.Acceleration * dt; Speed = Calc.Approach(Speed, Vector2.Zero, Type.Friction * dt); if (Type.SpeedMultiplier != 1) { Speed *= (float)Math.Pow(Type.SpeedMultiplier, dt); } //Scale Out if (Type.ScaleOut) { Size = StartSize * Ease.CubeOut(ease); } }