Example #1
0
    IEnumerator AnimateGet()
    {
        duration    = 1.5f;
        time_passed = 0.0f;

        Transform tfmEnd = pointDelivery.transform;

        tfmEnd.localScale.Set(1, 1, 1);

        Transform tfmStart = transform;

        Transform tfm = transform;

        while (time_passed < duration)
        {
            float t          = time_passed / duration;
            float tEasing    = Easing.CircularEaseIn(t);
            float tEasingPar = Easing.BackEaseInOut(tEasing);

            time_passed += Time.deltaTime;

            Vector3 pos   = tfm.position;
            Vector3 scale = tfm.localScale;

            pos.x = Mathf.Lerp(tfmStart.position.x, tfmEnd.position.x, tEasing);
            pos.y = Mathf.Lerp(tfmStart.position.y, tfmEnd.position.y, tEasing);
            pos.z = Mathf.Lerp(tfmStart.position.z, tfmEnd.position.z, tEasing);

            scale.x = Mathf.Lerp(tfmStart.localScale.x, tfmEnd.localScale.x, tEasing);
            scale.y = Mathf.Lerp(tfmStart.localScale.y, tfmEnd.localScale.y, tEasing);
            scale.z = Mathf.Lerp(tfmStart.localScale.z, tfmEnd.localScale.z, tEasing);

            pos            = pos + Vector3.up * Mathf.Sin(Time.deltaTime * -20f) * 20.0f;
            tfm.position   = pos;
            tfm.localScale = scale;

            yield return(null);
        }
    }
Example #2
0
    public Vector3 PositionBackInOut(Vector3 iniPosition, Vector3 finalPosition, float duration)
    {
        Vector3 easingValue = finalPosition;


        if (currentTime <= duration)
        {
            Vector3 deltaValue = finalPosition - iniPosition;
            easingValue = new Vector3(Easing.BackEaseInOut(currentTime, iniPosition.x, deltaValue.x, duration),
                                      Easing.BackEaseInOut(currentTime, iniPosition.y, deltaValue.y, duration),
                                      Easing.BackEaseInOut(currentTime, iniPosition.z, deltaValue.z, duration));
            currentTime += Time.deltaTime;

            if (currentTime > duration)
            {
                easingValue = finalPosition;
                return(easingValue);
            }
            return(easingValue);
        }

        return(easingValue);
    }
Example #3
0
    protected override void DoEasing()
    {
        switch (type)
        {
        case EasingType.LINEAR:
            easingValue = new Vector3(
                Easing.Linear(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.Linear(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.Linear(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOOUT:
            easingValue = new Vector3(
                Easing.ExpoEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOIN:
            easingValue = new Vector3(
                Easing.ExpoEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOINOUT:
            easingValue = new Vector3(
                Easing.ExpoEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOOUTIN:
            easingValue = new Vector3(
                Easing.ExpoEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCOUT:
            easingValue = new Vector3(
                Easing.CircEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCIN:
            easingValue = new Vector3(
                Easing.CircEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCINOUT:
            easingValue = new Vector3(
                Easing.CircEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCOUTIN:
            easingValue = new Vector3(
                Easing.CircEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADOUT:
            easingValue = new Vector3(
                Easing.QuadEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADIN:
            easingValue = new Vector3(
                Easing.QuadEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADINOUT:
            easingValue = new Vector3(
                Easing.QuadEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADOUTIN:
            easingValue = new Vector3(
                Easing.QuadEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEOUT:
            easingValue = new Vector3(
                Easing.SineEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEIN:
            easingValue = new Vector3(
                Easing.SineEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEINOUT:
            easingValue = new Vector3(
                Easing.SineEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEOUTIN:
            easingValue = new Vector3(
                Easing.SineEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICOUT:
            easingValue = new Vector3(
                Easing.CubicEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICIN:
            easingValue = new Vector3(
                Easing.CubicEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICINOUT:
            easingValue = new Vector3(
                Easing.CubicEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICOUTIN:
            easingValue = new Vector3(
                Easing.CubicEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTOUT:
            easingValue = new Vector3(
                Easing.QuartEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTIN:
            easingValue = new Vector3(
                Easing.QuartEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTINOUT:
            easingValue = new Vector3(
                Easing.QuartEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTOUTIN:
            easingValue = new Vector3(
                Easing.QuartEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTOUT:
            easingValue = new Vector3(
                Easing.QuintEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTIN:
            easingValue = new Vector3(
                Easing.QuintEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTINOUT:
            easingValue = new Vector3(
                Easing.QuintEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTOUTIN:
            easingValue = new Vector3(
                Easing.QuintEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICOUT:
            easingValue = new Vector3(
                Easing.ElasticEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICIN:
            easingValue = new Vector3(
                Easing.ElasticEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICINOUT:
            easingValue = new Vector3(
                Easing.ElasticEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICOUTIN:
            easingValue = new Vector3(
                Easing.ElasticEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEOUT:
            easingValue = new Vector3(
                Easing.BounceEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEIN:
            easingValue = new Vector3(
                Easing.BounceEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEINOUT:
            easingValue = new Vector3(
                Easing.BounceEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEOUTIN:
            easingValue = new Vector3(
                Easing.BounceEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKOUT:
            easingValue = new Vector3(
                Easing.BackEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKIN:
            easingValue = new Vector3(
                Easing.BackEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKINOUT:
            easingValue = new Vector3(
                Easing.BackEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKOUTIN:
            easingValue = new Vector3(
                Easing.BackEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        default:
            break;
        }

        switch (property)
        {
        case Property.POSITION:
            transform.localPosition = easingValue;
            break;

        case Property.ROTATION:
            transform.localRotation = Quaternion.Euler(easingValue);
            break;

        case Property.SCALE:
            transform.localScale = easingValue;
            break;

        default:
            break;
        }

        currentTime += Time.deltaTime;

        if (currentTime >= durationTime)
        {
            switch (property)
            {
            case Property.POSITION:
                transform.localPosition = finalValue;
                break;

            case Property.ROTATION:
                transform.localRotation = Quaternion.Euler(finalValue);
                break;

            case Property.SCALE:
                transform.localScale = finalValue;
                break;

            default:
                break;
            }

            currentTime = durationTime;

            Vector3 ini = finalValue;
            finalValue   = initialValue;
            initialValue = ini;
            deltaValue   = finalValue - initialValue;

            if (startGame != null)
            {
                startGame.StartLoad();
            }

            if (endScreenLogic != null)
            {
                endScreenLogic.LoadScene();
            }

            if (animLoop == true)
            {
                currentTime = 0;
            }
        }
    }
Example #4
0
    void EasingsUpdate()
    {
        if (GameCore.Instance.playerController.spawnGiantSun && (timeDelay > 0) && !GameCore.Instance.reviveFirstFrame)
        {
            timeDelay -= Time.deltaTime * 1000f;
        }
        else if (timeDelay > 0)
        {
            timeDelay -= Time.deltaTime;
        }
        else if (timeCounter < timeDuration)
        {
            if (GameCore.Instance.playerController.spawnGiantSun && !GameCore.Instance.reviveFirstFrame)
            {
                timeCounter += Time.deltaTime * 1000f;
            }
            else
            {
                timeCounter += Time.deltaTime;
            }

            #region Easings List
            switch (easingFunctionType)
            {
            case Easing.EasingFunctionType.BackEaseIn:
            {
                currentValue = (float)Easing.BackEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BackEaseInOut:
            {
                currentValue = (float)Easing.BackEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BackEaseOut:
            {
                currentValue = (float)Easing.BackEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BackEaseOutIn:
            {
                currentValue = (float)Easing.BackEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BounceEaseIn:
            {
                currentValue = (float)Easing.BounceEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BounceEaseInOut:
            {
                currentValue = (float)Easing.BounceEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BounceEaseOut:
            {
                currentValue = (float)Easing.BounceEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.BounceEaseOutIn:
            {
                currentValue = (float)Easing.BounceEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CircEaseIn:
            {
                currentValue = (float)Easing.CircEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CircEaseInOut:
            {
                currentValue = (float)Easing.CircEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CircEaseOut:
            {
                currentValue = (float)Easing.CircEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CircEaseOutIn:
            {
                currentValue = (float)Easing.CircEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CubicEaseIn:
            {
                currentValue = (float)Easing.CubicEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CubicEaseInOut:
            {
                currentValue = (float)Easing.CubicEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CubicEaseOut:
            {
                currentValue = (float)Easing.CubicEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.CubicEaseOutIn:
            {
                currentValue = (float)Easing.CubicEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ElasticEaseIn:
            {
                currentValue = (float)Easing.ElasticEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ElasticEaseInOut:
            {
                currentValue = (float)Easing.ElasticEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ElasticEaseOut:
            {
                currentValue = (float)Easing.ElasticEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ElasticEaseOutIn:
            {
                currentValue = (float)Easing.ElasticEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ExpoEaseIn:
            {
                currentValue = (float)Easing.ExpoEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ExpoEaseInOut:
            {
                currentValue = (float)Easing.ExpoEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ExpoEaseOut:
            {
                currentValue = (float)Easing.ExpoEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.ExpoEaseOutIn:
            {
                currentValue = (float)Easing.ExpoEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.Linear:
            {
                currentValue = (float)Easing.Linear(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuadEaseIn:
            {
                currentValue = (float)Easing.QuadEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuadEaseInOut:
            {
                currentValue = (float)Easing.QuadEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuadEaseOut:
            {
                currentValue = (float)Easing.QuadEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuadEaseOutIn:
            {
                currentValue = (float)Easing.QuadEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuartEaseIn:
            {
                currentValue = (float)Easing.QuartEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuartEaseInOut:
            {
                currentValue = (float)Easing.QuartEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuartEaseOut:
            {
                currentValue = (float)Easing.QuartEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuartEaseOutIn:
            {
                currentValue = (float)Easing.QuartEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuintEaseIn:
            {
                currentValue = (float)Easing.QuintEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuintEaseInOut:
            {
                currentValue = (float)Easing.QuintEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuintEaseOut:
            {
                currentValue = (float)Easing.QuintEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.QuintEaseOutIn:
            {
                currentValue = (float)Easing.QuintEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.SineEaseIn:
            {
                currentValue = (float)Easing.SineEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.SineEaseInOut:
            {
                currentValue = (float)Easing.SineEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.SineEaseOut:
            {
                currentValue = (float)Easing.SineEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;

            case Easing.EasingFunctionType.SineEaseOutIn:
            {
                currentValue = (float)Easing.SineEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration);
            }
            break;
            }
            //End Switch Here
            #endregion

            #region Easing Target Colors

            switch (easingTarget)
            {
            case Easing.EasingTarget.ColorR:
            {
                targetTransform.GetComponent <Renderer>().material.color = new Color(currentValue,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.g,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.b,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.a);
            }
            break;

            case Easing.EasingTarget.ColorG:
            {
                targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r,
                                                                                     currentValue,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.b,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.a);
            }
            break;

            case Easing.EasingTarget.ColorB:
            {
                targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.g,
                                                                                     currentValue,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.a);
            }
            break;

            case Easing.EasingTarget.ColorA:
            {
                targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.g,
                                                                                     targetTransform.GetComponent <Renderer>().material.color.b,
                                                                                     currentValue);
            }
            break;
            }
            #endregion

            #region Easing Transform Targets

            if (easingTargetRelativeSpace == Easing.EasingTargetRelativeSpace.WORLD)
            {
                switch (easingTarget)
                {
                case Easing.EasingTarget.PositionX:
                {
                    targetTransform.position = new Vector3(currentValue, targetTransform.position.y, targetTransform.position.z);
                }
                break;

                case Easing.EasingTarget.PositionY:
                {
                    targetTransform.position = new Vector3(targetTransform.position.x, currentValue, targetTransform.position.z);
                }
                break;

                case Easing.EasingTarget.PositionZ:
                {
                    targetTransform.position = new Vector3(targetTransform.position.x, targetTransform.position.y, currentValue);
                }
                break;

                case Easing.EasingTarget.RotationX:
                {
                    targetTransform.eulerAngles = new Vector3(currentValue, targetTransform.eulerAngles.y, targetTransform.eulerAngles.z);
                }
                break;

                case Easing.EasingTarget.RotationY:
                {
                    targetTransform.eulerAngles = new Vector3(targetTransform.eulerAngles.x, currentValue, targetTransform.eulerAngles.z);
                }
                break;

                case Easing.EasingTarget.RotationZ:
                {
                    targetTransform.eulerAngles = new Vector3(targetTransform.eulerAngles.x, targetTransform.eulerAngles.y, currentValue);
                }
                break;

                case Easing.EasingTarget.ScaleX:
                {
                    Debug.Log("Unity Engine doesn't have 'WORLD Scale'");
                }
                break;

                case Easing.EasingTarget.ScaleY:
                {
                    Debug.Log("Unity Engine doesn't have 'WORLD Scale'");
                }
                break;

                case Easing.EasingTarget.ScaleZ:
                {
                    Debug.Log("Unity Engine doesn't have 'WORLD Scale'");
                }
                break;

                case Easing.EasingTarget.ScaleALL:
                {
                    Debug.Log("Unity Engine doesn't have 'WORLD Scale'");
                }
                break;
                }
            }

            else if (easingTargetRelativeSpace == Easing.EasingTargetRelativeSpace.LOCAL)
            {
                switch (easingTarget)
                {
                case Easing.EasingTarget.PositionX:
                {
                    targetTransform.localPosition = new Vector3(currentValue, targetTransform.localPosition.y, targetTransform.localPosition.z);
                }
                break;

                case Easing.EasingTarget.PositionY:
                {
                    targetTransform.localPosition = new Vector3(targetTransform.position.x, currentValue, targetTransform.localPosition.z);
                }
                break;

                case Easing.EasingTarget.PositionZ:
                {
                    targetTransform.localPosition = new Vector3(targetTransform.localPosition.x, targetTransform.localPosition.y, currentValue);
                }
                break;

                case Easing.EasingTarget.RotationX:
                {
                    targetTransform.localEulerAngles = new Vector3(currentValue, targetTransform.localEulerAngles.y, targetTransform.localEulerAngles.z);
                }
                break;

                case Easing.EasingTarget.RotationY:
                {
                    targetTransform.localEulerAngles = new Vector3(targetTransform.localEulerAngles.x, currentValue, targetTransform.localEulerAngles.z);
                }
                break;

                case Easing.EasingTarget.RotationZ:
                {
                    targetTransform.localEulerAngles = new Vector3(targetTransform.localEulerAngles.x, targetTransform.localEulerAngles.y, currentValue);
                }
                break;

                case Easing.EasingTarget.ScaleX:
                {
                    targetTransform.localScale = new Vector3(currentValue, targetTransform.localScale.y, targetTransform.localScale.z);
                }
                break;

                case Easing.EasingTarget.ScaleY:
                {
                    targetTransform.localScale = new Vector3(targetTransform.localScale.x, currentValue, targetTransform.localScale.z);
                }
                break;

                case Easing.EasingTarget.ScaleZ:
                {
                    targetTransform.localScale = new Vector3(targetTransform.localScale.x, targetTransform.localScale.y, currentValue);
                }
                break;

                case Easing.EasingTarget.ScaleALL:
                {
                    targetTransform.localScale = new Vector3(currentValue, currentValue, currentValue);
                }
                break;
                }
            }
            #endregion
        }
        else
        {
            Restart();
        }
    }
Example #5
0
    private void Update()
    {            // Al final un easing se hace con un contador de tiempo
        // Easing - hay que calcularlos cada frame, porque si no nos darĂ­a un solo valor

        if (currentTime <= timeDuration)     // Mientras el momento actual sea menor o igual se harĂ¡ esto
        {
            // Do easing
            Vector3 easingValue = iniValue;
            if (startDelay > 0)     //Cuenta atras
            {
                startDelay -= Time.deltaTime;
                return;
            }

            switch (easings)
            {
            case Easings.expo:
                easingValue = new Vector3(Easing.ExpoEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.ExpoEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.circ:
                easingValue = new Vector3(Easing.CircEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.CircEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.quint:
                easingValue = new Vector3(Easing.QuintEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.QuintEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.quart:
                easingValue = new Vector3(Easing.QuartEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.QuartEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.quad:
                easingValue = new Vector3(Easing.QuadEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.QuadEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.sine:
                easingValue = new Vector3(Easing.SineEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.SineEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.SineEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.back:
                easingValue = new Vector3(Easing.BackEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.BackEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.bounce:
                easingValue = new Vector3(Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.BounceEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Easings.elastic:
                easingValue = new Vector3(Easing.ElasticEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                                          Easing.ElasticEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                                          Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            default:
                break;
            }

            transform.localPosition = easingValue;

            // Contador tiempo
            currentTime += Time.deltaTime;

            if (currentTime > timeDuration)     // En este momento se ha de acabar el easing
            {
                Debug.Log("El easing acaba de terminar justo ahora");
                transform.localPosition = finalValue;

                // Esto para que haga el efecto de ping pong, si no no hace falta, ya ha acabado
                if (pingPong)
                {
                    currentTime = 0;
                    Vector3 ini = iniValue;
                    iniValue   = finalValue;
                    finalValue = ini;
                    deltaValue = finalValue - iniValue;
                }
            }
        }

        else
        {
            Debug.Log("Easing terminado");
        }
    }
Example #6
0
    void Update()
    {
        if (currentTime <= timeDuration)
        {
            Vector3 easingValue = new Vector3();
            switch (type)
            {
            case Type.EXPO:
                easingValue = new Vector3(
                    Easing.ExpoEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.CIRC:
                easingValue = new Vector3(
                    Easing.CircEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUINT:
                easingValue = new Vector3(
                    Easing.QuintEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUART:
                easingValue = new Vector3(
                    Easing.QuartEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUAD:
                easingValue = new Vector3(
                    Easing.QuadEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.SINE:
                easingValue = new Vector3(
                    Easing.SineEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.SineEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.SineEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.BACK:
                easingValue = new Vector3(
                    Easing.BackEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.BOUNCE:
                easingValue = new Vector3(
                    Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.ELASTIC:
                easingValue = new Vector3(
                    Easing.ElasticEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;
            }

            switch (value)
            {
            case Value.position:
                transform.localPosition = easingValue;
                break;

            case Value.rotation:
                transform.localRotation = Quaternion.Euler(easingValue);
                break;

            case Value.scale:
                transform.localScale = easingValue;
                break;

            default:
                break;
            }

            currentTime += Time.deltaTime;

            if (currentTime > timeDuration)
            {
                switch (value)
                {
                case Value.position:
                    transform.localPosition = finalValue;
                    break;

                case Value.rotation:
                    transform.localRotation = Quaternion.Euler(finalValue);
                    break;

                case Value.scale:
                    transform.localScale = finalValue;
                    break;

                default:
                    break;
                }

                Debug.Log("El easing ha acabado");

                if (restart)
                {
                    currentTime = 0;
                }

                else if (pinpong)
                {
                    currentTime = 0;
                    Vector3 ini = iniValue;
                    iniValue   = finalValue;
                    finalValue = ini;
                    deltaValue = finalValue - iniValue;
                }
            }
        }

        else
        {
            Debug.Log("El easing hace un rato que ha acabado");
        }
    }
Example #7
0
    void Update()
    {
        if (currentTime <= timeDuration)
        {
            //DO EASING
            Vector3 easingValue = new Vector3();
            switch (type)
            {
            case Type.EXPO:
                easingValue = new Vector3(
                    Easing.ExpoEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.CIRC:
                easingValue = new Vector3(
                    Easing.CircEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUINT:
                easingValue = new Vector3(
                    Easing.QuintEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUART:
                easingValue = new Vector3(
                    Easing.QuartEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.QUAD:
                easingValue = new Vector3(
                    Easing.QuadEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.SINE:
                easingValue = new Vector3(
                    Easing.SineEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.SineEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.SineEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.BACK:
                easingValue = new Vector3(
                    Easing.BackEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.BOUNCE:
                easingValue = new Vector3(
                    Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case Type.ELASTIC:
                easingValue = new Vector3(
                    Easing.ElasticEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            default:
                break;
            }
            //easingValue.x = Easing.ExpoEaseOut(currentTime, iniValue.x, deltaValue.x, timeDuration);
            //easingValue.x = Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration);

            transform.localPosition = easingValue;

            if (restart)
            {
                currentTime += Time.deltaTime;
            }

            if (currentTime > timeDuration)
            {
                Debug.Log("EL EASING HA TERMINADO JUSTO AHORA");
                restart  = false;
                pingpong = true;
            }
        }
        else
        {
            Debug.Log("EL EASING HA TERMINADO HACE RATO YA");
        }

        if (pingpong)
        {
            currentTime -= Time.deltaTime;
        }

        if (currentTime <= 0)
        {
            restart  = true;
            pingpong = false;
        }
    }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        if (delayTime > 0)
        {
            delayTime -= Time.deltaTime;
            return;
        }
        if (currentTime <= timeDuration)
        {
            Vector3 easingValue = new Vector3();
            //Easings

            switch (easingType)
            {
            case easingTypes.Expo:
                easingValue = new Vector3(
                    Easing.ExpoEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Circ:
                easingValue = new Vector3(
                    Easing.CircEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Quint:
                easingValue = new Vector3(
                    Easing.QuintEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Quart:
                easingValue = new Vector3(
                    Easing.QuartEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Quad:
                easingValue = new Vector3(
                    Easing.QuadEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Sine:
                easingValue = new Vector3(
                    Easing.SineEaseIn(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.SineEaseIn(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.SineEaseIn(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Back:
                easingValue = new Vector3(
                    Easing.BackEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Bounce:
                easingValue = new Vector3(
                    Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            case easingTypes.Elastic:
                easingValue = new Vector3(
                    Easing.ElasticEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                    Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                break;

            default:
                break;
            }

            switch (type)
            {
            case types.position:
                this.transform.localPosition = easingValue;
                break;

            case types.rotation:
                this.transform.localRotation = Quaternion.Euler(easingValue);
                break;

            case types.scale:
                this.transform.localScale = easingValue;
                break;

            case types.all:
                break;

            default:
                break;
            }
            currentTime += Time.deltaTime;

            if (currentTime > timeDuration)
            {
                switch (type)
                {
                case types.position:
                    this.transform.localPosition = finalValue;
                    break;

                case types.rotation:
                    this.transform.localRotation = Quaternion.Euler(finalValue);
                    break;

                case types.scale:
                    this.transform.localScale = finalValue;
                    break;

                case types.all:
                    break;

                default:
                    break;
                }

                if (pingPong)
                {
                    Vector3 ini = iniValue;
                    iniValue    = finalValue;
                    finalValue  = ini;
                    deltaValue  = finalValue - iniValue;
                    currentTime = 0;
                }

                if (reset)
                {
                    currentTime = 0;
                }

                if (resetDelay)
                {
                    delayTime = delayTimeSave;
                }
            }
        }
        else
        {
        }
    }
Example #9
0
    protected override void DoEasing()
    {
        switch (type)
        {
        case EasingType.LINEAR:
            easingValue = new Vector3(
                Easing.Linear(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.Linear(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.Linear(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOOUT:
            easingValue = new Vector3(
                Easing.ExpoEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOIN:
            easingValue = new Vector3(
                Easing.ExpoEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOINOUT:
            easingValue = new Vector3(
                Easing.ExpoEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.EXPOOUTIN:
            easingValue = new Vector3(
                Easing.ExpoEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ExpoEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ExpoEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCOUT:
            easingValue = new Vector3(
                Easing.CircEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCIN:
            easingValue = new Vector3(
                Easing.CircEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCINOUT:
            easingValue = new Vector3(
                Easing.CircEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CIRCOUTIN:
            easingValue = new Vector3(
                Easing.CircEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CircEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CircEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADOUT:
            easingValue = new Vector3(
                Easing.QuadEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADIN:
            easingValue = new Vector3(
                Easing.QuadEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADINOUT:
            easingValue = new Vector3(
                Easing.QuadEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUADOUTIN:
            easingValue = new Vector3(
                Easing.QuadEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuadEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuadEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEOUT:
            easingValue = new Vector3(
                Easing.SineEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEIN:
            easingValue = new Vector3(
                Easing.SineEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEINOUT:
            easingValue = new Vector3(
                Easing.SineEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.SINEOUTIN:
            easingValue = new Vector3(
                Easing.SineEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.SineEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.SineEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICOUT:
            easingValue = new Vector3(
                Easing.CubicEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICIN:
            easingValue = new Vector3(
                Easing.CubicEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICINOUT:
            easingValue = new Vector3(
                Easing.CubicEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.CUBICOUTIN:
            easingValue = new Vector3(
                Easing.CubicEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.CubicEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.CubicEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTOUT:
            easingValue = new Vector3(
                Easing.QuartEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTIN:
            easingValue = new Vector3(
                Easing.QuartEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTINOUT:
            easingValue = new Vector3(
                Easing.QuartEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUARTOUTIN:
            easingValue = new Vector3(
                Easing.QuartEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuartEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuartEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTOUT:
            easingValue = new Vector3(
                Easing.QuintEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTIN:
            easingValue = new Vector3(
                Easing.QuintEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTINOUT:
            easingValue = new Vector3(
                Easing.QuintEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.QUINTOUTIN:
            easingValue = new Vector3(
                Easing.QuintEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.QuintEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.QuintEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICOUT:
            easingValue = new Vector3(
                Easing.ElasticEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICIN:
            easingValue = new Vector3(
                Easing.ElasticEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICINOUT:
            easingValue = new Vector3(
                Easing.ElasticEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.ELASTICOUTIN:
            easingValue = new Vector3(
                Easing.ElasticEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.ElasticEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.ElasticEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEOUT:
            easingValue = new Vector3(
                Easing.BounceEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEIN:
            easingValue = new Vector3(
                Easing.BounceEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEINOUT:
            easingValue = new Vector3(
                Easing.BounceEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BOUNCEOUTIN:
            easingValue = new Vector3(
                Easing.BounceEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BounceEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BounceEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKOUT:
            easingValue = new Vector3(
                Easing.BackEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKIN:
            easingValue = new Vector3(
                Easing.BackEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKINOUT:
            easingValue = new Vector3(
                Easing.BackEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        case EasingType.BACKOUTIN:
            easingValue = new Vector3(
                Easing.BackEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime),
                Easing.BackEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime),
                Easing.BackEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime));
            break;

        default:
            break;
        }

        switch (property)
        {
        case Property.POSITION:
            transform.position = easingValue;
            break;

        case Property.ROTATION:
            transform.localRotation = Quaternion.Euler(easingValue);
            break;

        case Property.SCALE:
            transform.localScale = easingValue;
            break;

        default:
            break;
        }

        currentTime += Time.deltaTime;

        if (currentTime >= durationTime)
        {
            switch (property)
            {
            case Property.POSITION:
                transform.position = finalValue;
                break;

            case Property.ROTATION:
                transform.localRotation = Quaternion.Euler(finalValue);
                break;

            case Property.SCALE:
                transform.localScale = finalValue;
                break;

            default:
                break;
            }

            currentTime = durationTime;

            Vector3 ini = finalValue;
            finalValue   = initialValue;
            initialValue = ini;
            deltaValue   = finalValue - initialValue;

            if (loopCounter > 0)
            {
                currentTime = 0;
                loopCounter--;
            }
            //else
            //{
            //    cooldown.Activate();
            //    loopCounter = 1;
            //}
        }
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        if (currentTime <= timeDuration && laps < 2)
        {
            int easingValue = 0;
            //Easings
            switch (easingType)
            {
            case easingTypes.Expo:
                easingValue = (int)Easing.ExpoEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Circ:
                easingValue = (int)Easing.CircEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Quint:
                easingValue = (int)Easing.QuintEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Quart:
                easingValue = (int)Easing.QuartEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Quad:
                easingValue = (int)Easing.QuadEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Sine:
                easingValue = (int)Easing.SineEaseIn(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Back:
                easingValue = (int)Easing.BackEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Bounce:
                easingValue = (int)Easing.BounceEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            case easingTypes.Elastic:
                easingValue = (int)Easing.ElasticEaseInOut(currentTime, iniValue, deltaValue, timeDuration);
                break;

            default:
                break;
            }

            this.gameObject.GetComponent <Text>().fontSize = (int)easingValue;
            currentTime += Time.deltaTime;

            if (currentTime > timeDuration)
            {
                this.gameObject.GetComponent <Text>().fontSize = finalValue;

                if (pingPong)
                {
                    int ini = iniValue;
                    iniValue    = finalValue;
                    finalValue  = ini;
                    deltaValue  = finalValue - iniValue;
                    currentTime = 0;
                    ++laps;
                    if (laps >= 2)
                    {
                        this.gameObject.GetComponent <Text>().color = Color.white;
                    }
                }
            }
        }
        else
        {
            //nothing
        }
    }
Example #11
0
    void Update()
    {
        startDelay -= Time.deltaTime;

        if (startDelay <= 0)
        {
            startDelay = 0;
            if (currentTime <= timeDuration)
            {
                //DO EASING
                Vector3 easingValue = new Vector3();
                switch (type)
                {
                case Type.EXPO:
                    easingValue = new Vector3(
                        Easing.ExpoEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.ExpoEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.CIRC:
                    easingValue = new Vector3(
                        Easing.CircEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.CircEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.QUINT:
                    easingValue = new Vector3(
                        Easing.QuintEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.QuintEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.QUART:
                    easingValue = new Vector3(
                        Easing.QuartEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.QuartEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.QUAD:
                    easingValue = new Vector3(
                        Easing.QuadEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.QuadEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.SINE:
                    easingValue = new Vector3(
                        Easing.SineEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.SineEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.SineEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.BACK:
                    easingValue = new Vector3(
                        Easing.BackEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.BackEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.BOUNCE:
                    easingValue = new Vector3(
                        Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.BounceEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Type.ELASTIC:
                    easingValue = new Vector3(
                        Easing.ElasticEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration),
                        Easing.ElasticEaseInOut(currentTime, iniValue.y, deltaValue.y, timeDuration),
                        Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                default:
                    break;
                }
                //easingValue.x = Easing.ExpoEaseOut(currentTime, iniValue.x, deltaValue.x, timeDuration);
                //easingValue.x = Easing.BounceEaseInOut(currentTime, iniValue.x, deltaValue.x, timeDuration);

                transform.localRotation = Quaternion.Euler(easingValue);

                currentTime += Time.deltaTime;

                if (currentTime > timeDuration)
                {
                    Debug.Log("EL EASING HA TERMINADO JUSTO AHORA");
                }
            }
            else
            {
                Debug.Log("EL EASING HA TERMINADO HACE RATO YA");
            }
        }
    }
Example #12
0
 public static float BackEaseInOut(float t, float b, float c, float d)
 {
     return(Easing.BackEaseInOut(t, b, c - b, d));
 }
Example #13
0
 public static double BackEaseInOut(double t, double b, double c, double d)
 {
     return(Easing.BackEaseInOut(t, b, c - b, d));
 }
Example #14
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            start = true;
        }
        if (start)
        {
            // Al final un easing se hace con un contador de tiempo
            // Easing - hay que calcularlos cada frame, porque si no nos darĂ­a un solo valor
            if (currentTime <= timeDuration)
            {
                // Do easing
                Quaternion easingValue = Quaternion.Euler(iniValue); // Hay que convertirlo a Quaternion

                if (startDelay > 0)                                  //Cuenta atras
                {
                    startDelay -= Time.deltaTime;
                    return;
                }

                switch (easings)
                {
                case Easings.expo:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.ExpoEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.circ:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.CircEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.quint:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.QuintEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.quart:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.QuartEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.quad:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.QuadEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.sine:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.SineEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.back:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.BackEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.bounce:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.BounceEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                case Easings.elastic:
                    easingValue = Quaternion.Euler(finalValue.x, finalValue.y, Easing.ElasticEaseInOut(currentTime, iniValue.z, deltaValue.z, timeDuration));
                    break;

                default:
                    break;
                }

                transform.localRotation = easingValue;

                currentTime += Time.deltaTime;

                if (currentTime > timeDuration)
                {
                    Debug.Log("El easing acaba de terminar justo ahora");
                    transform.localRotation = Quaternion.Euler(finalValue);

                    if (pingPong)
                    {
                        currentTime = 0;
                        Vector3 ini = iniValue;
                        iniValue   = finalValue;
                        finalValue = ini;
                        deltaValue = finalValue - iniValue;
                    }
                }
            }

            else
            {
                Debug.Log("Easing terminado");
            }
        }
    }
Example #15
0
    void Update()
    {
        if (m_CurrentTime <= m_EasingDuration && m_CurrentDeleyTime >= m_StarFixedtDelay)
        {
            if (m_CurrentDeleyTime > m_StarFixedtDelay)
            {
                m_CurrentDeleyTime = m_StarFixedtDelay;
            }

            Vector3 l_EasingValue = new Vector3();
            float   l_EsingAlpha  = 0f;

            switch (m_EasingType)
            {
            case TEasingType.EXPO:
                l_EasingValue = new Vector3(Easing.ExpoEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.ExpoEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.ExpoEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.ExpoEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.CIRC:
                l_EasingValue = new Vector3(Easing.CircEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.CircEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.CircEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.CircEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.QUINT:
                l_EasingValue = new Vector3(Easing.QuintEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.QuintEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.QuintEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.QuintEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.QUART:
                l_EasingValue = new Vector3(Easing.QuartEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.QuartEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.QuartEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.QuartEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.QUAD:
                l_EasingValue = new Vector3(Easing.QuadEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.QuadEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.QuadEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.QuadEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.SINE:
                l_EasingValue = new Vector3(Easing.SineEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.SineEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.SineEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.SineEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.BACK:
                l_EasingValue = new Vector3(Easing.BackEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.BackEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.BackEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.BackEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.BOUNCE:
                l_EasingValue = new Vector3(Easing.BounceEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.BounceEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.BounceEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.BounceEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            case TEasingType.ELASTIC:
                l_EasingValue = new Vector3(Easing.ElasticEaseInOut(m_CurrentTime, m_InitalValue.x, m_DeltaValue.x, m_EasingDuration),
                                            Easing.ElasticEaseInOut(m_CurrentTime, m_InitalValue.y, m_DeltaValue.y, m_EasingDuration),
                                            Easing.ElasticEaseInOut(m_CurrentTime, m_InitalValue.z, m_DeltaValue.z, m_EasingDuration));
                if (m_ChangeAlpha)
                {
                    l_EsingAlpha = Easing.ElasticEaseInOut(m_CurrentTime, m_AlphaValues.x, m_AlphaDeltaValue, m_EasingDuration);
                }
                break;

            default:
                break;
            }

            switch (m_TransformSelected)
            {
            case TTransformSelected.POSITION:
                transform.localPosition = l_EasingValue;
                break;

            case TTransformSelected.ROTATE:
                transform.localRotation = Quaternion.Euler(l_EasingValue);
                break;

            case TTransformSelected.SCALE:
                transform.localScale = l_EasingValue;
                break;

            case TTransformSelected.FILLED:
                Image l_image = GetComponent <Image>();
                l_image.fillAmount = l_EsingAlpha;
                break;

            case TTransformSelected.ALL:
                //transform.localPosition = l_EasingValue;
                transform.localRotation = Quaternion.Euler(l_EasingValue);
                transform.localScale    = l_EasingValue / 10;
                break;

            default:
                break;
            }

            if (m_ChangeAlpha && !m_ChangeFilled)
            {
                m_ColorEasing.a = l_EsingAlpha;
                m_Image.color   = m_ColorEasing;
            }

            m_CurrentTime += Time.deltaTime;

            if (m_CurrentTime > m_EasingDuration)
            {
                switch (m_TransformSelected)
                {
                case TTransformSelected.POSITION:
                    transform.localPosition = m_FinalValue;
                    break;

                case TTransformSelected.ROTATE:
                    transform.localRotation = Quaternion.Euler(m_FinalValue);
                    break;

                case TTransformSelected.SCALE:
                    transform.localScale = m_FinalValue;
                    break;

                default:
                    break;
                }

                if (m_ChangeAlpha)
                {
                    m_ColorEasing.a = m_AlphaValues.y;
                    m_Image.color   = m_ColorEasing;
                }

                if (m_Restart)
                {
                    if (m_ResetDelay)
                    {
                        m_CurrentDeleyTime = 0;
                    }
                    m_CurrentTime = 0;
                }
                else if (m_PingPong)
                {
                    if (m_ResetDelay)
                    {
                        m_CurrentDeleyTime = 0;
                    }
                    m_CurrentTime = 0;
                    Vector3 l_Initial = m_InitalValue;
                    m_InitalValue = m_FinalValue;
                    m_FinalValue  = l_Initial;
                    m_DeltaValue  = m_FinalValue - m_InitalValue;

                    float l_AlphaInitial = m_AlphaValues.x;
                    m_AlphaValues.x   = m_AlphaValues.y;
                    m_AlphaValues.y   = l_AlphaInitial;
                    m_AlphaDeltaValue = m_AlphaValues.y - m_AlphaValues.x;
                }
            }
        }
        else
        {
            m_CurrentDeleyTime += Time.deltaTime;
        }
    }