コード例 #1
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;
            }
        }
    }
コード例 #2
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();
        }
    }
コード例 #3
0
ファイル: EasingTo.cs プロジェクト: Deprion/AxGridTools
 public static float BounceEaseOutIn(float t, float b, float c, float d)
 {
     return(Easing.BounceEaseOutIn(t, b, c - b, d));
 }
コード例 #4
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;
            //}
        }
    }
コード例 #5
0
ファイル: EasingTo.cs プロジェクト: Deprion/AxGridTools
 public static double BounceEaseOutIn(double t, double b, double c, double d)
 {
     return(Easing.BounceEaseOutIn(t, b, c - b, d));
 }