Example #1
0
    IEnumerator OpenDoor()
    {
        if (keyProgress == null)
        {
            keyProgress = Instantiate <Transform>(keyProgressPrefab);
            keyProgress.transform.position = key.transform.position.SwapZ(10);
            keyProgress.localScale         = Vector3.zero;
        }

        LerpDelegate openFunc = delegate(float openFraction) {
            openProgress = openFraction;
            SetBallSize(openProgress);
            SetDoorAlpha(1 - openProgress);
        };

        IEnumerator lerpCoroutine = LerpHelper.Lerp(openFunc, secondsToOpen);

        while (lerpCoroutine.MoveNext())
        {
            yield return(null);
        }

        //yield return StartCoroutine(LerpHelper.Lerp(openFunc, secondsToOpen));

        doorOpened = true;
        door.SetActive(false);
    }
Example #2
0
    public LerpInfo(LerpDelegate lerpF,
	                float min, float max, float time, CallbackDelegate cb=null)
    {
        this.lerpF=lerpF;
        this.lerpMin=min;
        this.lerpMax=max;
        this.lerpTime=time;
        this.lerp=0f;
        this.lerpCB=cb;
    }
Example #3
0
        public static IEnumerator LerpCoroutine(LerpDelegate method, float startValue, float endValue, float lerpDuration)
        {
            float lerpT = 0;

            while (lerpT < 1)
            {
                lerpT += Time.deltaTime / lerpDuration;
                lerpT  = Mathf.Clamp(lerpT, 0, 1);
                float value = Mathf.Lerp(startValue, endValue, lerpT);
                method(value);
                yield return(new WaitForEndOfFrame());
            }
        }
Example #4
0
    public static IEnumerator Lerp(LerpDelegate fadeFunc, float duration)
    {
        float elapsedTime = 0.0f;

        while (elapsedTime < duration)
        {
            yield return(null);

            elapsedTime += Time.deltaTime;
            fadeFunc(elapsedTime / duration);
        }
        yield return(null);
    }
Example #5
0
    IEnumerator CloseDoor()
    {
        float startingProgress = openProgress;

        LerpDelegate closeFunc = delegate(float timeFraction) {
            openProgress = startingProgress - startingProgress * timeFraction;

            SetBallSize(openProgress);
            SetDoorAlpha(1 - openProgress);
        };

        yield return(StartCoroutine(LerpHelper.Lerp(closeFunc, secondsToOpen * startingProgress)));
    }
Example #6
0
    public override void OnFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols)
#endif
    {
        int VertStart = verts.size;
        int UVStart   = uvs.size;
        int ColStart  = cols.size;

        base.OnFill(verts, uvs, cols);

        switch (mGradientDirection)
        {
        case GradientDirection.LeftToRight:
            mLerpFunction = fLeftToRight;
            break;

        case GradientDirection.RightToLeft:
            mLerpFunction = fRightToLeft;
            break;

        case GradientDirection.TopToBottom:
            mLerpFunction = fTopToBottom;
            break;

        case GradientDirection.BottomToTop:
            mLerpFunction = fBottomToTop;
            break;

        default:
            mLerpFunction = fLeftToRight;
            break;
        }

        for (int i = VertStart, j = ColStart; i < verts.size; ++i, ++j)
        {
            float f = mLerpFunction(verts[i]);
            cols[j] = Color.Lerp(color, mGradientColor, mCurve.Evaluate(f));
        }
    }
    public override void OnFill(BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
#endif
    {
        int VertStart = verts.size;
        int UVStart = uvs.size;
        int ColStart = cols.size;

        base.OnFill(verts, uvs, cols);
        
        switch( mGradientDirection )
        {
            case GradientDirection.LeftToRight:
                mLerpFunction = fLeftToRight;
                break;
            case GradientDirection.RightToLeft:
                mLerpFunction = fRightToLeft;
                break;
            case GradientDirection.TopToBottom:
                mLerpFunction = fTopToBottom;
                break;
            case GradientDirection.BottomToTop:
                mLerpFunction = fBottomToTop;
                break;

            default:
                mLerpFunction = fLeftToRight;
                break;
        }

        for (int i = VertStart, j = ColStart ; i < verts.size; ++i,++j)
        {
            float f = mLerpFunction(verts[i]);
            cols[j] = Color.Lerp(color, mGradientColor, mCurve.Evaluate(f));
        }

    }
Example #8
0
 public static void RegisterLerper(LerpDelegate lerpF, float min, float max, float time, CallbackDelegate cb=null)
 {
     mLerpers.Add(new LerpInfo(lerpF, min, max, time, cb));
 }
 /// For convenience
 private static MethodInfo GetLerpMethod <TVal>(LerpDelegate <TVal> del)
 {
     return(del.Method);
 }
 /// For convenience
 private static void AddLerpMethod <TVal>(IDictionary <Type, MethodInfo> dict, LerpDelegate <TVal> del)
 {
     dict.Add(typeof(TVal), GetLerpMethod(del));
 }
Example #11
0
 public ValueLerper(GameObject gameObject_, LerpDelegate lerper_)
 {
     gameObject = gameObject_;
     lerper     = lerper_;
 }
Example #12
0
 public static void Register <T>(LerpDelegate <T> @delegate)
 {
     Cache <T> .instance = @delegate;
 }