private Vector3 SmoothMove()
    {
        if (t <= 1.0)
        {
            t += Time.deltaTime / GetCurrentSeconds();
            float newTime = t;
            if (newTime > 1)
            {
                newTime = 1;
            }
            float easeFactor = newTime;

            EASING_FUNCTION easing = GetCurrentEasing();

            if (easing == EASING_FUNCTION.INOUTCUBIC)
            {
                easeFactor = EasingFunction.EaseInOutCubic(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.BOUNCE)
            {
                easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.ELASTIC)
            {
                easeFactor = EasingFunction.EaseOutElastic(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.INEXPO)
            {
                easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.OUTEXPO)
            {
                easeFactor = EasingFunction.EaseOutExpo(0.0F, 1.0F, newTime);
            }

            Vector3 newPosition            = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor);
            Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition);


            return(pixelPerfectMoveAmount - transform.position);
        }

        if (currentEndpos == endpos && myRenderer.isVisible)
        {
            ActionCompleteEffect();
        }

        isMoving        = false;
        isMovingAction  = false;
        isMovingPrewarm = false;

        if (currentEndpos == endpos)
        {
            waitUntil       = Time.timeSinceLevelLoad + waitTimeActionPosition;
            currentStartPos = endpos;
            currentEndpos   = startPos;
        }
        else
        {
            if (currentEndpos == prewarmPos)
            {
                PrewarmEffect();
                isMovingAction  = true;
                waitUntil       = Time.timeSinceLevelLoad + waitTimePrewarmPosition;
                currentStartPos = prewarmPos;
                currentEndpos   = endpos;
            }
            else
            {
                isMovingPrewarm = true;
                waitUntil       = Time.timeSinceLevelLoad + waitTimeBasePosition;
                currentStartPos = startPos;
                currentEndpos   = prewarmPos;
            }
        }

        return(Vector3.zero);
    }
Пример #2
0
    private Vector3 SmoothMove()
    {
        if (t <= 1.0)
        {
            t += Time.deltaTime / GetCurrentSeconds();
            float newTime = t;
            if (newTime > 1)
            {
                newTime = 1;
            }
            float easeFactor = newTime;

            EASING_FUNCTION easing = GetCurrentEasing();

            if (easing == EASING_FUNCTION.INOUTCUBIC)
            {
                easeFactor = EasingFunction.EaseInOutCubic(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.BOUNCE)
            {
                easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.ELASTIC)
            {
                easeFactor = EasingFunction.EaseOutElastic(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.INEXPO)
            {
                easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime);
            }
            if (easing == EASING_FUNCTION.OUTEXPO)
            {
                easeFactor = EasingFunction.EaseOutExpo(0.0F, 1.0F, newTime);
            }

            if (isMovingAction && Time.frameCount % 2 == 0)
            {
                InstantiateEffect(fallingEffect, transform.position);
            }

            Vector3 newPosition            = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor);
            Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition);

            if (!actionCompleteEffectPlayed &&
                ((easing != EASING_FUNCTION.BOUNCE && newPosition == endpos) || (easing == EASING_FUNCTION.BOUNCE && (newPosition.y > transform.position.y))))
            {
                ActionCompleteEffect();
            }

            return(pixelPerfectMoveAmount - transform.position);
        }



        isMoving        = false;
        isMovingAction  = false;
        isMovingPrewarm = false;

        if (currentEndpos == endpos)
        {
            waitUntil                  = waitUntil + secondsAction + waitTimeActionPosition;
            currentStartPos            = endpos;
            currentEndpos              = startPos;
            actionCompleteEffectPlayed = false;
        }
        else
        {
            isMovingPrewarm = true;
            waitUntil       = waitUntil + secondsBase + waitTimeBasePosition;
            currentStartPos = startPos;
            currentEndpos   = endpos;
        }

        return(Vector3.zero);
    }