Beispiel #1
0
 public void StartShake(float duration, ValueAtNormalizedTime MagnitudeAt, float speed, bool loop = false)
 {
     Reset();
     SetShake(duration, -1, speed, loop);
     this.MagnitudeAt = MagnitudeAt;
     Shake();
 }
Beispiel #2
0
 public void StopShake(float fadeOutDuration = 0f)
 {
     if (isShaking)
     {
         if (fadeOutDuration == 0f)
         {
             if (shakeCoroutine != null)
             {
                 StopCoroutine(shakeCoroutine);
             }
             Reset();
         }
         else
         {
             isLoop = false;
             if (magnitude == -1)
             {
                 magnitude = MagnitudeAt(totalETime / duration);
             }
             if (speed == -1)
             {
                 speed = SpeedAt(totalETime / duration);
             }
             totalETime = 0f;
             duration   = fadeOutDuration;
             float m = magnitude;
             float s = speed;
             MagnitudeAt = (t) => { return(m * (1 - t)); };
             SpeedAt     = (t) => { return(s * (1 - t)); };
             magnitude   = -1;
             speed       = -1;
         }
     }
 }
Beispiel #3
0
 void Reset(bool resetFunctions = false)
 {
     duration = 0f;
     if (resetFunctions)
     {
         MagnitudeAt = (t) => { return(t); };
         SpeedAt     = (t) => { return(t); };
     }
     magnitude  = -1f;
     speed      = -1f;
     isLoop     = false;
     totalETime = 0f;
     isShaking  = false;
     if (transformToShake != null)
     {
         transformToShake.localPosition = originalPosition;
     }
 }