Ejemplo n.º 1
0
        private void DoUpdate(ref ITween tween, ref TweenConfig param)
        {
            if (tween.pState == TweenState.PAUSE || tween.pState == TweenState.DONE)
            {
                return;
            }
            if (tween.pId == -1 || tween.pState == TweenState.DONE)
            {
                Remove(ref tween);
                return;
            }

            if (tween.pDelayCounter < param.pDelay)
            {
                tween.pDelayCounter += deltaTime;
                return;
            }

            tween.pValue = Mathf.MoveTowards(tween.pValue, 1, deltaTime * param.pDelta);

            if (param.pUseAnimationCurve)
            {
                mValue = param.pAnimationCurve.Evaluate(tween.pValue);
            }
            else
            {
                mValue = param.pCustomAnimationCurve(0, 1, tween.pValue);
            }

            tween.DoAnim(!tween.pDoInReverese ? mValue : 1 - mValue);

            if (tween.pValue >= 1)
            {
                tween.pValue        = 0;
                tween.pDoInReverese = param.pPingPong ? !tween.pDoInReverese : tween.pDoInReverese;
                ++tween.pCompletedLoopCount;

                if (!(tween.pCompletedLoopCount != (param.pPingPong ? param.pLoopCount != 1 ? 2 * param.pLoopCount : 2 : param.pLoopCount)))
                {
                    tween.pState = TweenState.DONE;
                    param.pOnTweenCompleteCallback?.Invoke(null);
                    param.OnTweeningComplete?.Invoke();
                    Remove(ref tween);
                }
            }
        }