Example #1
0
        /// <summary>
        /// Update one step and return result
        /// </summary>
        /// <param name="sp">Parameters of Smoothing ( can be modified in inspector)</param>
        /// <returns>Smooth result</returns>
        public Vector4 Update(SmoothingParameters sp)
        {
            if (_Current != Target && !Mathf.Approximately(Time.timeScale, 0))
            {
                switch (sp.SmoothType)
                {
                case SmoothType.Damp:
                    _Current.x = Mathf.SmoothDamp(_Current.x, _Target.x, ref _CurrentVelocity.x, sp.SmoothTime);
                    _Current.y = Mathf.SmoothDamp(_Current.y, _Target.y, ref _CurrentVelocity.x, sp.SmoothTime);
                    _Current.z = Mathf.SmoothDamp(_Current.z, _Target.z, ref _CurrentVelocity.x, sp.SmoothTime);
                    _Current.w = Mathf.SmoothDamp(_Current.w, _Target.w, ref _CurrentVelocity.x, sp.SmoothTime);
                    break;

                case SmoothType.DampSpeed:
                    _Current.x = Mathf.SmoothDamp(_Current.x, _Target.x, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed);
                    _Current.y = Mathf.SmoothDamp(_Current.y, _Target.y, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed);
                    _Current.z = Mathf.SmoothDamp(_Current.z, _Target.z, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed);
                    _Current.w = Mathf.SmoothDamp(_Current.w, _Target.w, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed);
                    break;

                case SmoothType.DampSpeedAndTime:
                    float time = Time.deltaTime * sp.DeltaTimeFactor;
                    _Current.x = Mathf.SmoothDamp(_Current.x, _Target.x, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed, time);
                    _Current.y = Mathf.SmoothDamp(_Current.y, _Target.y, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed, time);
                    _Current.z = Mathf.SmoothDamp(_Current.z, _Target.z, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed, time);
                    _Current.w = Mathf.SmoothDamp(_Current.w, _Target.w, ref _CurrentVelocity.x, sp.SmoothTime, sp.MaxSpeed, time);
                    break;
                }
            }
            return(_Current);
        }
Example #2
0
 private void FadeOut()
 {
     this.FadeScreen.FadeToOne();
     Skill.Framework.Audio.DynamicSoundVolume[] sounds = FindObjectsOfType <Skill.Framework.Audio.DynamicSoundVolume>();
     if (sounds != null)
     {
         SmoothingParameters fading = new SmoothingParameters()
         {
             SmoothTime = this.FadeScreen.FadeOutTime - 0.1f, SmoothType = SmoothType.Damp
         };
         foreach (var item in sounds)
         {
             item.Fading       = fading;
             item.VolumeFactor = 0;
         }
     }
 }
Example #3
0
        /// <summary>
        /// Update one step and return result
        /// </summary>
        /// <param name="sp">Parameters of Smoothing ( can be modified in inspector)</param>
        /// <returns>Smooth result</returns>
        public float Update(SmoothingParameters sp)
        {
            if (_CurrentAngle != TargetAngle && !Mathf.Approximately(Time.timeScale, 0))
            {
                switch (sp.SmoothType)
                {
                case SmoothType.Damp:
                    _CurrentAngle = Mathf.SmoothDampAngle(_CurrentAngle, _TargetAngle, ref _CurrentAngleVelocity, sp.SmoothTime);
                    break;

                case SmoothType.DampSpeed:
                    _CurrentAngle = Mathf.SmoothDampAngle(_CurrentAngle, _TargetAngle, ref _CurrentAngleVelocity, sp.SmoothTime, sp.MaxSpeed);
                    break;

                case SmoothType.DampSpeedAndTime:
                    float time = Time.deltaTime * sp.DeltaTimeFactor;
                    _CurrentAngle = Mathf.SmoothDampAngle(_CurrentAngle, _TargetAngle, ref _CurrentAngleVelocity, sp.SmoothTime, sp.MaxSpeed, time);
                    break;
                }
            }

            return(_CurrentAngle);
        }