Esempio n. 1
0
    /// <summary>
    /// Update the moving to tile state
    /// </summary>
    /// <param name="dt"></param>
    private void UpdateMovingToTile(float dt)
    {
        if (shouldWaitBeforeMovingToTile)
        {
            beforeMovingTimer += dt;

            if (beforeMovingTimer >= timeToWaitDoorToOpen)
            {
                shouldWaitBeforeMovingToTile = false;
                beforeMovingTimer            = 0.0f;
                return;
            }
        }

        timeMovingToTile += dt;

        float t = timeMovingToTile / timeToMoveBetweenTiles;

        t = Mathf.Clamp01(t);

        float s = CustomInterpolation.Interpolate(t, interpFunction);

        moveTo = CalcPlayerPositionOverTile(tileMovingTo);

        Vector3 newPos = Vector3.Lerp(moveFrom, moveTo, s);

        transform.position = newPos;

        RotateVisualsTowardsNextTile(dt);

        if (t >= 1.0f)
        {
            SwitchState(PlayerState.Idle, false);
        }
    }
    /// <summary>
    /// Update the fade in state
    /// </summary>
    /// <param name="dt"></param>
    private void UpdateFadingIn(float dt)
    {
        float t = timer / timeToFade;

        t = Mathf.Clamp01(t);
        float   s        = CustomInterpolation.Interpolate(t, fadeType);
        Vector3 newScale = Vector3.Lerp(fadedOutValue, fadedInValue, s);

        SetCurrScale(newScale);

        if (t >= 1.0f)
        {
            OnFinishedFadingIn();
            SwitchState(FadeState.FadedIn, 0.0f, false);
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Update the fade in state
    /// </summary>
    /// <param name="dt"></param>
    private void UpdateFadingIn(float dt)
    {
        float t = timer / timeToFade;

        t = Mathf.Clamp01(t);
        float s = CustomInterpolation.Interpolate(t, fadeType);

        s = Mathf.Lerp(fadedOutValue, fadedInValue, s);

        SetCurrFocusDistance(s);

        if (t >= 1.0f)
        {
            SwitchState(FadeState.FadedIn, 0.0f, false);
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Update the fade out state
    /// </summary>
    /// <param name="dt"></param>
    private void UpdateFadingOut(float dt)
    {
        float t = timer / timeToFade;

        t = Mathf.Clamp01(t);
        t = 1.0f - t;
        float s = CustomInterpolation.Interpolate(t, fadeType);

        s = Mathf.Lerp(fadedOutValue, fadedInValue, s);

        SetCurrVolume(s);

        if (t <= 0.0f)
        {
            OnFinishedFadingOut();
            SwitchState(FadeState.FadedOut, 0.0f, false);
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Update the moving state
    /// </summary>
    /// <param name="dt"></param>
    private void UpdateMoving(float dt)
    {
        float t = timer / timeToMoveBetweenTiles;

        t = Mathf.Clamp01(t);

        float s = CustomInterpolation.Interpolate(t, movingFunction);

        Vector3 initPos = CalcPositionOverTile(path[currPathPoint]);

        Tile    nextTile = GetNextTile();
        Vector3 endPos   = CalcPositionOverTile(nextTile);

        Vector3 newPos = Vector3.Lerp(initPos, endPos, s);

        transform.position = newPos;

        if (t >= 1.0f)
        {
            // exit moving
            SwitchState(EnemyState.Idle, false);
            RefreshCurrentTile(GetNextTile());
        }
    }