Example #1
0
 public void SetOtherNumbers(float time, float rewind, TypeOfLerp T, LerpMode M, bool callback)
 {
     timeToTake     = time;      //Map the amount of time to take.
     TimeTillRewind = rewind;    //Map the amount of time till starting the rewind.
     CurrentType    = T;         //Map the type of lerp.
     CurrentMode    = M;         //Map the mode of the lerp.
 }
    /// <summary>
    /// Used to modify the "t" value in a lerp function.
    /// </summary>
    /// <param name="lerpMode"></param>
    /// <param name="t"></param>
    /// <returns></returns>
    public static float ChangeLerpT(LerpMode lerpMode = LerpMode.EaseOut, float t = 0f)
    {
        switch (lerpMode)
        {
        case LerpMode.EaseIn:
            t = 1f - Mathf.Cos(t * Mathf.PI * 0.5f);
            break;

        case LerpMode.EaseOut:
            t = Mathf.Sin(t * Mathf.PI * 0.5f);
            break;

        case LerpMode.Exponential:
            t = t * t;
            break;

        case LerpMode.Smoothstep:
            t = t * t * t * (t * (6f * t - 15f) + 10f);
            break;

        case LerpMode.None:
            break;

        default:
            t = t * t * t * (t * (6f * t - 15f) + 10f);
            break;
        }
        return(t);
    }
 public void SwitchLerp(LerpMode lerpMode)
 {
     //ResetartTime ();
     this.lerpMode = lerpMode;
 }
 public Color32InterPolation(Color32 starPos, Color32 endPos)
 {
     this.startPos = starPos;
     this.endPos   = endPos;
     lerpMode      = LerpMode.Smootherstep;
 }
 public FloatInterpolation(float starPos, float endPos)
 {
     this.startPos = starPos;
     this.endPos   = endPos;
     lerpMode      = LerpMode.Smootherstep;
 }
 public FloatInterpolation()
 {
     this.startPos = 0f;
     this.endPos   = 0f;
     lerpMode      = LerpMode.Smootherstep;
 }
Example #7
0
    public void StartLerp(Func <int> currentIdGetter, Func <float> lerpedVariableGetter, Action <float> lerpedVariableSetter, float targetValue, float lerpDuration, LerpMode lerpMode, UnityEvent onFinishEvent, Action onFinishFunction)
    {
        if (lerpDuration > 0.0f)
        {
            switch (lerpMode)
            {
            case LerpMode.NormalLerp:
                StartCoroutine(CustomLerp(new LerpObject(currentIdGetter, lerpedVariableGetter, lerpedVariableSetter, targetValue, lerpDuration, NormalLerp, onFinishEvent, onFinishFunction)));
                break;

            case LerpMode.EaseOutLerp:
                StartCoroutine(CustomLerp(new LerpObject(currentIdGetter, lerpedVariableGetter, lerpedVariableSetter, targetValue, lerpDuration, EaseOutLerp, onFinishEvent, onFinishFunction)));
                break;

            case LerpMode.EaseInLerp:
                StartCoroutine(CustomLerp(new LerpObject(currentIdGetter, lerpedVariableGetter, lerpedVariableSetter, targetValue, lerpDuration, EaseInLerp, onFinishEvent, onFinishFunction)));
                break;

            case LerpMode.SmoothLerp:
                StartCoroutine(CustomLerp(new LerpObject(currentIdGetter, lerpedVariableGetter, lerpedVariableSetter, targetValue, lerpDuration, SmoothLerp, onFinishEvent, onFinishFunction)));
                break;

            case LerpMode.SmootherLerp:
                StartCoroutine(CustomLerp(new LerpObject(currentIdGetter, lerpedVariableGetter, lerpedVariableSetter, targetValue, lerpDuration, SmootherLerp, onFinishEvent, onFinishFunction)));
                break;
            }
        }
        else
        {
            lerpedVariableSetter(targetValue);
            if (onFinishEvent != null)
            {
                onFinishEvent.Invoke();
            }
            if (onFinishFunction != null)
            {
                onFinishFunction();
            }
        }
    }