Ejemplo n.º 1
0
    /// <summary>
    /// Tweens a value, starting at _from by _delta amount over duration seconds
    /// </summary>
    public static float Tween(float _from, float _delta, float duration, float curtime, easing_family fam, easing_type type)
    {
        if (curtime >= duration)
        {
            return(_from + _delta);
        }
        else if (curtime <= 0)
        {
            return(_from);
        }
        switch (fam)
        {
        case easing_family.linear:
            return(Ease_Linear(_from, _delta, duration, curtime));

        case easing_family.quadratic:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Quadratic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Quadratic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Quadratic(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.cubic:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Cubic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Cubic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Cubic(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.quartic:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Quartic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Quartic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Quartic(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.quintic:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Quintic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Quintic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Quintic(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.sine:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Sine(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Sine(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Sine(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.exponential:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Exponential(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Exponential(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Exponential(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.circular:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Circular(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Circular(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Circular(_from, _delta, duration, curtime));
            }
            break;

        case easing_family.elastic:
            if (type == easing_type.ease_in)
            {
                return(EaseIn_Elastic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_out)
            {
                return(EaseOut_Elastic(_from, _delta, duration, curtime));
            }
            if (type == easing_type.ease_inout)
            {
                return(EaseInOut_Elastic(_from, _delta, duration, curtime));
            }
            break;
        }
        return(0f);
    }
Ejemplo n.º 2
0
    public static Vector3 Tween(Vector3 _from, Vector3 _to, float duration, float curtime, easing_family fam, easing_type type)
    {
        Vector3 toReturn = new Vector3();

        for (int i = 0; i < 3; i++)
        {
            toReturn [i] = Tween(_from [i], _to [i], duration, curtime, fam, type);
        }
        return(toReturn);
    }