Exemple #1
0
        public void OnUpdate(float?delta = null)
        {
            float num1 = !delta.HasValue ? Time.deltaTime : delta.Value;
            float t    = this.Life / this.StartLife;

            this.Life -= num1;
            if ((double)this.Life <= 0.0)
            {
                this.gameObject.SetActive(false);
            }
            else
            {
                if (this.Type.RotationMode == ParticleType.RotationModes.SameAsDirection)
                {
                    if (this.Speed != Vector2.zero)
                    {
                        this.Rotation = this.Speed.Angle();
                    }
                }
                else
                {
                    this.Rotation += this.Spin * num1;
                }
                float num2 = this.Type.FadeMode != ParticleType.FadeModes.Linear ? (this.Type.FadeMode != ParticleType.FadeModes.Late ? (this.Type.FadeMode != ParticleType.FadeModes.InAndOut ? 1f : ((double)t <= 0.75 ? ((double)t >= 0.25 ? 1f : t / 0.25f) : (float)(1.0 - ((double)t - 0.75) / 0.25))) : Math.Min(1f, t / 0.25f)) : t;
                if ((double)num2 == 0.0)
                {
                    this.Color = new Color(Color.r, Color.g, Color.b, 0);
                }
                else
                {
                    if (this.Type.ColorMode == ParticleType.ColorModes.Static)
                    {
                        this.Color = this.StartColor;
                    }
                    else if (this.Type.ColorMode == ParticleType.ColorModes.Fade)
                    {
                        this.Color = Color.Lerp(this.Type.Color2, this.StartColor, t);
                    }
                    else if (this.Type.ColorMode == ParticleType.ColorModes.Blink)
                    {
                        this.Color = RandomUtil.BetweenInterval(this.Life, 0.1f) ? this.StartColor : this.Type.Color2;
                    }
                    else if (this.Type.ColorMode == ParticleType.ColorModes.Choose)
                    {
                        this.Color = this.StartColor;
                    }
                    if ((double)num2 < 1.0)
                    {
                        this.Color = this.Color * num2;
                    }
                }
                this.Position = (this.Position + this.Speed * num1);
                this.Speed    = this.Speed + this.Type.Acceleration * num1;
                this.Speed    = Util.Approach(this.Speed, Vector2.zero, this.Type.Friction * num1);
                if ((double)this.Type.SpeedMultiplier != 1.0)
                {
                    this.Speed = this.Speed * (float)Math.Pow((double)this.Type.SpeedMultiplier, (double)num1);
                }
                if (!this.Type.ScaleOut)
                {
                    return;
                }
                this.Size = this.StartSize * Ease.CubeOut(t);
            }
        }