Beispiel #1
0
 public override void HandleMovementProjection(ref Vector3 movement, Vector3 obstructionNormal, bool stableOnHit)
 {
     if (Mathf.Abs(Vector3.Dot(obstructionNormal, Vector3.up)) < 0.2f)
     {
         movement = Vector3.ProjectOnPlane(movement, obstructionNormal).normalized *
                    movement.magnitude *
                    (1f - Mathf.Clamp01(EasingFunction.EaseInOutSine(0f, 1f, Mathf.Abs(Vector3.Dot(transform.TransformDirection(_moveInput), obstructionNormal)))));
     }
 }
Beispiel #2
0
    void UpdateType()
    {
        switch (type)
        {
        case PlatformType.falling:
            if (falling)
            {
                fallSpeed    += gravity;
                offsetMove.y += fallSpeed;
            }

            if (touchedEver)
            {
                fallTimer -= Utils.cappedDeltaTime;
                falling    = fallTimer <= 0;
            }
            else if (touched)
            {
                touchedEver = true;
                fallTimer   = fallWaitTime;
            }
            break;

        case PlatformType.moving:
            moveTime += Utils.cappedDeltaTime;
            moveTime %= moveTimeMax;
            float movePercentage = 1 - Mathf.Abs(((moveTime / moveTimeMax) - 0.5F) * 2);

            offsetMove.x = EasingFunction.EaseInOutSine(
                0,
                moveDestination.x - offsetOriginal.x,
                movePercentage
                );
            offsetMove.y = EasingFunction.EaseInOutSine(
                0,
                moveDestination.y - offsetOriginal.y,
                movePercentage
                );
            offsetMove.z = EasingFunction.EaseInOutSine(
                0,
                moveDestination.z - offsetOriginal.z,
                movePercentage
                );
            break;
        }
    }
Beispiel #3
0
    IEnumerator FadeInAndMoveText(GameObject target, float timeToWaitBeforeFade, float timeOfTravel, Vector2 startPos, Vector2 endPos)
    {
        yield return(new WaitForSecondsRealtime(timeToWaitBeforeFade));

        float currentTime = 0f;
        float normalizedValue;

        while (currentTime <= timeOfTravel)
        {
            currentTime    += Time.unscaledDeltaTime;
            normalizedValue = currentTime / timeOfTravel;

            target.GetComponent <CanvasGroup>().alpha = EasingFunction.EaseInOutSine(0f, 1f, normalizedValue);
            target.GetComponent <RectTransform>().anchoredPosition = Vector2.Lerp(startPos, endPos, EasingFunction.EaseOutExpo(0f, 1f, normalizedValue));
            yield return(null);
        }
    }
Beispiel #4
0
    private Vector3 SmoothMove()
    {
        if (t <= 1.0)
        {
            t += Time.deltaTime / seconds;
            float newTime = t;
            if (newTime > 1)
            {
                newTime = 1;
            }
            float   easeFactor  = EasingFunction.EaseInOutSine(0.0F, 1.0F, newTime);
            Vector3 newPosition = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor);

            return(newPosition - transform.position);
        }
        run = false;
        animator.SetBool("OUT", true);
        return(Vector3.zero);
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (!introTextDone)
        {
            t = Time.time;
            if (t > IntroStaticTextHoldSec)
            {
                clamped_t = Mathf.Clamp((t - IntroStaticTextHoldSec) / (IntroStaticTextSec - IntroStaticTextHoldSec),
                                        0.0f, 1.0f);

                lerpedColor = Color.Lerp(Color.white, Color.clear, clamped_t);
                img01.color = lerpedColor;
            }
            if (t > IntroStaticTextSec)
            {
                introTextDone = true;
            }
        }


        //if (introTextDone) {
        if (Time.time > IntroStaticTextHoldSec)
        {
            animationTimeLapsed += Time.deltaTime;
            if (animationTimeLapsed < animationTimeSec && parameter < 1.0f)
            {
                parameter += Time.deltaTime / animationTimeSec;

                camPosCursor.DistanceRatio = EasingFunction.EaseInOutSine(0.0f, 1.0f, parameter);
                //camRotCursor.DistanceRatio = EasingFunction.EaseInOutQuad (0.0f, 1.0f, animationTimeLapsed / animationTimeSec);
                camRotCursor.DistanceRatio = camPosCursor.DistanceRatio;
            }
            else
            {
                parameter = 1.0f;
            }
        }
    }