easeInOutSine() public static méthode

public static easeInOutSine ( float start, float end, float val ) : float
start float
end float
val float
Résultat float
Exemple #1
0
        private void InterpolateCameraZoom(int currentLevel)
        {
            if (LeanTween.isTweening(_cameraZoomId))
            {
                return;
            }

            var bounds = _levelBounds[currentLevel];
            var mid    = (bounds.Item1 + bounds.Item2) / 2f;

            // Interpolate camera zoom between levels
            var yPos             = transform.position.y;
            var delta            = -mid + yPos;
            var closestNextLevel = delta < 0
                                ? (currentLevel <= 0 ? 0 : currentLevel - 1)
                                : (currentLevel >= _levelBounds.Length - 1 ? _levelBounds.Length - 1 : currentLevel + 1);
            var nextBounds = _levelBounds[closestNextLevel];
            var nextMid    = (nextBounds.Item1 + nextBounds.Item2) / 2f;
            var deltaRatio = Mathf.Abs(delta) > Mathf.Abs(nextMid - mid) ? 1f : Mathf.Abs(delta) / Mathf.Abs(nextMid - mid);

            var puzzleScale       = _levels[_selectedLevel].GetComponent <PuzzleScale>();
            var selectedLevelZoom = CameraScript.CameraZoomToFit(puzzleScale.Dimensions, puzzleScale.Margin, _scaleRatio);

            var nextPuzzleScale = _levels[closestNextLevel].GetComponent <PuzzleScale>();
            var nextLevelZoom   = CameraScript.CameraZoomToFit(nextPuzzleScale.Dimensions, nextPuzzleScale.Margin, _scaleRatio);

            Camera.main.orthographicSize = LeanTween.easeInOutSine(selectedLevelZoom, nextLevelZoom, deltaRatio);
        }
Exemple #2
0
 private IEnumerator Start()
 {
     while (true)
     {
         float totalTime       = 1f;
         float targetRotation2 = Mathf.Sign(UnityEngine.Random.Range(-1, 1)) * 30f;
         float prevRotation    = base.transform.rotation.eulerAngles.z;
         int   num;
         for (int i = 1; i <= 6; i = num)
         {
             totalTime       /= (float)i;
             targetRotation2  = 0f - targetRotation2;
             targetRotation2 /= (float)i;
             for (float t = 0f; t < totalTime; t += Time.unscaledDeltaTime)
             {
                 float t2 = LeanTween.easeInOutSine(0f, 1f, t / totalTime);
                 float z  = Mathf.LerpAngle(prevRotation, targetRotation2, t2);
                 base.transform.rotation = Quaternion.Euler(0f, 0f, z);
                 yield return(null);
             }
             prevRotation = targetRotation2;
             num          = i + 1;
         }
         yield return(new WaitForSecondsRealtime(0.5f));
     }
 }
Exemple #3
0
    private void Update()
    {
        Quaternion identity = Quaternion.identity;

        identity = ((!lockWorld) ? base.transform.rotation : world);
        time    += Time.deltaTime;
        float val = Mathf.PingPong(time, 1f);

        if (time > 2f)
        {
            time -= 2f;
        }
        identity *= Quaternion.Euler(Vector3.Lerp(from, to, LeanTween.easeInOutSine(0f, 1f, val)));
        base.transform.rotation = identity;
    }
Exemple #4
0
        public float GetValue(float start, float end, float t)
        {
            switch (Easing)
            {
            case LeanTweenType.notUsed:
                return(0f);

            case LeanTweenType.animationCurve:
                return(Mathf.Lerp(start, end, AnimationCurve.Evaluate(t)));

            case LeanTweenType.linear:
                return(LeanTween.linear(start, end, t));

            case LeanTweenType.easeOutQuad:
                return(LeanTween.easeOutQuad(start, end, t));

            case LeanTweenType.easeInQuad:
                return(LeanTween.easeInQuad(start, end, t));

            case LeanTweenType.easeInOutQuad:
                return(LeanTween.easeInOutQuad(start, end, t));

            case LeanTweenType.easeInCubic:
                return(LeanTween.easeInCubic(start, end, t));

            case LeanTweenType.easeOutCubic:
                return(LeanTween.easeOutCubic(start, end, t));

            case LeanTweenType.easeInOutCubic:
                return(LeanTween.easeInOutCubic(start, end, t));

            case LeanTweenType.easeInQuart:
                return(LeanTween.easeInQuart(start, end, t));

            case LeanTweenType.easeOutQuart:
                return(LeanTween.easeOutQuart(start, end, t));

            case LeanTweenType.easeInOutQuart:
                return(LeanTween.easeInOutQuart(start, end, t));

            case LeanTweenType.easeInQuint:
                return(LeanTween.easeInQuint(start, end, t));

            case LeanTweenType.easeOutQuint:
                return(LeanTween.easeOutQuint(start, end, t));

            case LeanTweenType.easeInOutQuint:
                return(LeanTween.easeInOutQuint(start, end, t));

            case LeanTweenType.easeInSine:
                return(LeanTween.easeInSine(start, end, t));

            case LeanTweenType.easeOutSine:
                return(LeanTween.easeOutSine(start, end, t));

            case LeanTweenType.easeInOutSine:
                return(LeanTween.easeInOutSine(start, end, t));

            case LeanTweenType.easeInExpo:
                return(LeanTween.easeInExpo(start, end, t));

            case LeanTweenType.easeOutExpo:
                return(LeanTween.easeOutExpo(start, end, t));

            case LeanTweenType.easeInOutExpo:
                return(LeanTween.easeInOutExpo(start, end, t));

            case LeanTweenType.easeInCirc:
                return(LeanTween.easeInCirc(start, end, t));

            case LeanTweenType.easeOutCirc:
                return(LeanTween.easeOutCirc(start, end, t));

            case LeanTweenType.easeInOutCirc:
                return(LeanTween.easeInOutCirc(start, end, t));

            case LeanTweenType.easeInBounce:
                return(LeanTween.easeInBounce(start, end, t));

            case LeanTweenType.easeOutBounce:
                return(LeanTween.easeOutBounce(start, end, t));

            case LeanTweenType.easeInOutBounce:
                return(LeanTween.easeInOutBounce(start, end, t));

            case LeanTweenType.easeInBack:
                return(LeanTween.easeInBack(start, end, t));

            case LeanTweenType.easeOutBack:
                return(LeanTween.easeOutBack(start, end, t));

            case LeanTweenType.easeInOutBack:
                return(LeanTween.easeInOutBack(start, end, t));

            case LeanTweenType.easeInElastic:
                return(LeanTween.easeInElastic(start, end, t));

            case LeanTweenType.easeOutElastic:
                return(LeanTween.easeOutElastic(start, end, t));

            case LeanTweenType.easeInOutElastic:
                return(LeanTween.easeInOutElastic(start, end, t));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }