public void OnUpdate()
    {
        const float maxParamValue = 65.0f;

        switch (mState)
        {
            case 0: break;
            case 1:
                {
                    mTimeElapsed += FrameController.DT();

                    float currParamValue = mTimeElapsed / mMaxTimeInMaze * maxParamValue;
                    if (currParamValue > maxParamValue) // Cap to 65 (max)
                    {
                        mState = 0;
                        currParamValue = maxParamValue;
                    }
                    mSound.SetUniqueEventParam(mMazeAmbientID, mMazeAmbientParam, currParamValue);

                    // Play once the creepy sound when around the middle of the time elapsed
                    if (!hasCreepSoundPlayed && mTimeElapsed >= mMaxTimeInMaze*0.4f)
                    {
                        hasCreepSoundPlayed = true;
                        mSound.PlayIndependentEvent("PERCUSSIVE_A.vente", false, 0);
                    }
                }
                break;
            case 2:
                {
                    mTimeElapsed += FrameController.DT();

                    float currParamValue = mTimeElapsed / mTimeToRelease * maxParamValue;
                    currParamValue = maxParamValue - currParamValue; // Count down from 65 to 0
                    if (currParamValue < 0.0f)
                    {
                        mState = 0;
                        currParamValue = 0.0f;
                        mSound.StopUniqueEvent(mMazeAmbientID, false);
                    }
                    else
                    {
                        mSound.SetUniqueEventParam(mMazeAmbientID, mMazeAmbientParam, currParamValue);
                    }
                }
                break;
        }
    }
    public void OnUpdate()
    {
        if (isTriggered && glassCrackLevel < 3)
        {
            Vector3 glassToPlayer = (Vector3)Common.GetStealthPlayer().transform.position - (Vector3)gameObject.transform.position;
            float   dist          = Vector3.Dot(glassToPlayer, mDirectionToRun); // distance player is from trigger
            mDistanceRan = Math.Max(dist, mDistanceRan);                         // Always take the max
            float paramValue = mDistanceRan / mMaxDistanceToRun * 3;             // [0, 3]

            if ((int)Math.Floor(paramValue) > glassCrackLevel)
            {
                ++glassCrackLevel;
                mSound.PlayUniqueEvent(glassCrackID, false);
                mSound.SetUniqueEventParam(glassCrackID, glassCrackParam, (float)glassCrackLevel);
            }
        }
    }
Example #3
0
    public void OnUpdate()
    {
        if (mIsSoundPlaying)
        {
            Vector3 triggerToPlayer = (Vector3)Common.GetStealthPlayer().transform.position - (Vector3)gameObject.transform.position;
            float   dist            = Vector3.Dot(triggerToPlayer, mDirectionToRun);    // distance player is from trigger
            mDistanceRan = Math.Max(dist, mDistanceRan);                                // Always take the max
            float paramValue = mDistanceRan / mMaxDistanceToRun * mMaxEscapeParamValue; // [0, maxParam]
            mSound.SetUniqueEventParam(mEscapeEventID, mEscapeParam, paramValue);
        }

        if (!isactive)
        {
        }
        else
        {
            float dt = FrameController.DT();

            if (hasPlayerSprinted)
            {
                if (mTimer > 0.0f)
                {
                    mTimer -= dt;
                    if (mTimer <= 0.0f)
                    {
                        isPromptShown = 2; // Start tweening off
                    }
                }
            }
            else
            {
                if (playerScript != null && playerScript.sprintLocked == true)
                {
                    hasPlayerSprinted = true;
                    mTimer            = mEndDelayTime;
                }
            }

            switch (isPromptShown)
            {
            case 0:
                mTimer -= dt;
                if (mTimer <= 0.0f)
                {
                    isPromptShown = 1;     // Start tweening on
                    mTimer        = mEndDelayTime;
                }
                break;

            case 1:     // Tweening up opacity
                mCurrOpacity += 1.0f / mFadeTime * dt;
                if (mCurrOpacity >= 1.0f)
                {
                    isPromptShown = 3;
                }
                Common.SetOpacityToAllUI(mCurrOpacity, tutorialIconObj);
                break;

            case 2:     // Tweening down to 0 opacity
                mCurrOpacity -= 1.0f / mFadeTime * dt;
                if (mCurrOpacity <= 0.0f)
                {
                    isPromptShown = 0;
                    Common.SetOpacityToAllUI(mCurrOpacity, tutorialIconObj);
                    isactive = false;     // When 0 opacity, destroy this object, since it will never show again
                    return;
                }
                Common.SetOpacityToAllUI(mCurrOpacity, tutorialIconObj);
                break;
            }
        }
    }