private void FadeOut(float fadeCurtainTime = 2f, float fadeMusicTime = 1.5f)
 {
     fadeScript.StartFadingToColor(fadeCurtainTime);
     if (fadeMusicTime != -1f)
     {
         rsc.audioMng.FadeOutMusic(fadeMusicTime);
     }
 }
    // Update is called once per frame
    void Update()
    {
        elapsedTime += Time.deltaTime;

        switch (state)
        {
        case IntroState.FadingIn:
            if (!fadeScript.FadingToClear)
            {
                skipHint.SetActive(true);
                state = IntroState.Playing;
            }
            break;

        case IntroState.Playing:
            if (InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action2) ||
                elapsedTime >= startFadingTime)
            {
                skipHint.SetActive(false);
                fadeScript.StartFadingToColor(1f);
                rsc.audioMng.FadeOutMusic(1f);
                state = IntroState.FadingOut;
            }

            break;

        case IntroState.FadingOut:
            if (!fadeScript.FadingToColor)
            {
                //SceneManager.LoadScene("Level01");
                async.allowSceneActivation = true;
            }
            break;

        default:
            break;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case TeamState.FADING_IN:
            if (!fadeScript.FadingToClear)
            {
                elapsedTime  = 0f;
                currentState = TeamState.TEAM;
            }
            break;

        case TeamState.TEAM:
            if (elapsedTime >= chromaTeamTime)
            {
                fadeScript.StartFadingToColor(fadeToPresentTime / 2);
                currentState = TeamState.FADING_OUT_TO_PRESENT;
            }
            else
            {
                elapsedTime += Time.deltaTime;
            }
            break;

        case TeamState.FADING_OUT_TO_PRESENT:
            if (!fadeScript.FadingToColor)
            {
                teamGroupGO.SetActive(false);
                presentsGroupGO.SetActive(true);
                fadeScript.StartFadingToClear(fadeToPresentTime / 2);

                currentState = TeamState.FADING_IN_TO_PRESENT;
            }
            break;

        case TeamState.FADING_IN_TO_PRESENT:
            if (!fadeScript.FadingToClear)
            {
                elapsedTime  = 0f;
                currentState = TeamState.PRESENT;
            }
            break;

        case TeamState.PRESENT:
            if (elapsedTime >= presentsTime)
            {
                //fadeScript.StartFadingToColor(fadeToMenuTime);
                glitch.enabled = true;
                glitchSoundFx.Play();
                elapsedTime  = 0f;
                currentState = TeamState.GLITCH;
            }
            else
            {
                elapsedTime += Time.deltaTime;
            }
            break;

        case TeamState.FADING_OUT:
            if (!fadeScript.FadingToColor)
            {
                loadMainMenu.allowSceneActivation = true;
            }
            break;

        case TeamState.GLITCH:
            if (elapsedTime >= fadeToMenuTime)
            {
                glitchSoundFx.Stop();
                loadMainMenu.allowSceneActivation = true;
            }
            else
            {
                elapsedTime += Time.deltaTime;
            }
            break;
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (changeTime >= changeEverySeconds)
        {
            ++currentColorIndex;
            if (currentColorIndex >= colors.Length)
            {
                currentColorIndex = 0;
            }

            StartCoroutine(ChangeColor(colors[currentColorIndex]));
            changeTime = 0f;
        }
        else
        {
            changeTime += Time.deltaTime;
        }

        switch (currentState)
        {
        case CreditsState.FADING_IN:
            if (!fadeScript.FadingToClear)
            {
                currentState = CreditsState.IDLE;
                //Set focus on first slider
            }
            break;


        case CreditsState.FADING_OUT:
            if (!fadeScript.FadingToColor)
            {
                loadingScene.allowSceneActivation = true;
                //SceneManager.LoadScene("MainMenu");
            }
            break;
        }


        if (!buttonPressed &&
            (InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action1) ||
             InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action2)))
        {
            buttonPressed = true;

            if (InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action1))
            {
                rsc.audioMng.acceptFx.Play();
                SaveValues();
            }
            else
            {
                rsc.audioMng.backFx.Play();
                RestoreValues();
            }

            if (currentState != CreditsState.FADING_OUT)
            {
                loadingScene = SceneManager.LoadSceneAsync("MainMenu");
                loadingScene.allowSceneActivation = false;

                fadeScript.StartFadingToColor(fadeOutTime);
                currentState = CreditsState.FADING_OUT;
                //rsc.audioMng.FadeOutMusic(fadeOutTime);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case State.FADING_IN:
            if (!fadeScript.FadingToClear)
            {
                skipHint.SetActive(true);

                elapsedTime = 0;

                loadingStr = "LOADING";
                state      = State.LOADING;
            }
            break;

        case State.LOADING:
            if (elapsedTime < loadingDuration)
            {
                float factor     = elapsedTime / loadingDuration;
                int   percentage = Mathf.CeilToInt(Mathf.Lerp(0, loadingUntil, factor));

                loadingSlider.value    = percentage;
                percentageSlider.value = percentage;

                percentageBackgroundText.text = percentage + "%";
                percentageForegroundText.text = percentage + "%";

                elapsedTime += Time.deltaTime;
            }
            else
            {
                //alertArea.SetActive(true);
                alertTriangle.SetActive(true);
                exclamationMark.SetActive(true);

                blinkExclamation = StartCoroutine(BlinkExclamationMark());
                //rotateCircle = StartCoroutine(RotateCircles());

                alarmSoundFx.Play();

                elapsedTime = 0f;

                loadingStr = "CHROMAvIRUS DETECTED";
                state      = State.VIRUS_DETECTED;
            }
            break;

        case State.VIRUS_DETECTED:
            if (elapsedTime > virusDetectedDuration)
            {
                StopCoroutine(blinkExclamation);
                StopCoroutine(rotateCircle);
                StartCoroutine(FadeAlertArea());
                //alertArea.SetActive(false);

                rsc.audioMng.FadeOutExternalMusic(alarmSoundFx, 1f);

                //backgroundMat.color = backgroundInfectedTint;
                background.color     = backgroundInfectedTint;
                leftTriangles.color  = trianglesInfectedTint;
                rightTriangles.color = trianglesInfectedTint;

                //Set kdt

                /*wireBase.SetFloat("_Thickness", 0f);
                *  wireColor.SetFloat("_Thickness", 0f);
                *  wireFace.SetFloat("_Thickness", 0f);*/
                wireBase.SetFloat("_V_WIRE_Size", 0f);
                wireColor.SetFloat("_V_WIRE_Size", 0f);
                wireFace.SetFloat("_V_WIRE_Size", 0f);

                kdt.SetActive(true);

                //Set jnk
                jnkWireBase.SetFloat("_V_WIRE_Size", 0f);
                jnkWireColor.SetFloat("_V_WIRE_Size", 0f);
                jnkWireFace.SetFloat("_V_WIRE_Size", 0f);

                if (multiPlayer)
                {
                    jnk.SetActive(true);
                }

                elapsedTime = 0f;

                loadingStr = "STARTING KDT PROTOCOL";
                state      = State.STARTING_KDT_1;
            }
            else
            {
                float factor = elapsedTime / virusDetectedDuration;

                //backgroundMat.color = Color.Lerp(backgroundInitialTint, backgroundInfectedTint, factor);
                background.color     = Color.Lerp(backgroundInitialTint, backgroundInfectedTint, factor);
                leftTriangles.color  = Color.Lerp(trianglesInitialTint, trianglesInfectedTint, factor);
                rightTriangles.color = Color.Lerp(trianglesInitialTint, trianglesInfectedTint, factor);

                elapsedTime += Time.deltaTime;
            }
            break;

        case State.STARTING_KDT_1:
            if (elapsedTime < startingKDT1Duration)
            {
                float factor     = elapsedTime / startingKDT1Duration;
                int   percentage = Mathf.CeilToInt(Mathf.Lerp(loadingUntil, startingKDT1Until, factor));

                loadingSlider.value    = percentage;
                percentageSlider.value = percentage;

                percentageBackgroundText.text = percentage + "%";
                percentageForegroundText.text = percentage + "%";

                if (elapsedTime >= startingKDT1InitialDelay)
                {
                    factor = (elapsedTime - startingKDT1InitialDelay) / (startingKDT1Duration - startingKDT1InitialDelay);
                    float thickness = Mathf.Lerp(0, wireMiddleThickness, factor);
                    wireBase.SetFloat("_V_WIRE_Size", thickness);
                    wireColor.SetFloat("_V_WIRE_Size", thickness);
                    wireFace.SetFloat("_V_WIRE_Size", thickness);

                    jnkWireBase.SetFloat("_V_WIRE_Size", thickness);
                    jnkWireColor.SetFloat("_V_WIRE_Size", thickness);
                    jnkWireFace.SetFloat("_V_WIRE_Size", thickness);
                }

                kdt.transform.Rotate(0, Time.deltaTime * startingKdtDPS, 0);

                jnk.transform.Rotate(0, Time.deltaTime * startingKdtDPS, 0);

                elapsedTime += Time.deltaTime;
            }
            else
            {
                elapsedTime = 0f;

                state = State.STARTING_KDT_2;
            }
            break;

        case State.STARTING_KDT_2:
            if (elapsedTime < startingKDT2Duration)
            {
                float factor     = elapsedTime / startingKDT2Duration;
                int   percentage = Mathf.CeilToInt(Mathf.Lerp(startingKDT1Until, startingKDT2Until, factor));

                loadingSlider.value    = percentage;
                percentageSlider.value = percentage;

                percentageBackgroundText.text = percentage + "%";
                percentageForegroundText.text = percentage + "%";

                float thickness = Mathf.Lerp(wireMiddleThickness, wireMaxThickness, factor);
                wireBase.SetFloat("_V_WIRE_Size", thickness);
                wireColor.SetFloat("_V_WIRE_Size", thickness);
                wireFace.SetFloat("_V_WIRE_Size", thickness);

                jnkWireBase.SetFloat("_V_WIRE_Size", thickness);
                jnkWireColor.SetFloat("_V_WIRE_Size", thickness);
                jnkWireFace.SetFloat("_V_WIRE_Size", thickness);

                kdt.transform.Rotate(0, Time.deltaTime * startingKdtDPS, 0);

                jnk.transform.Rotate(0, Time.deltaTime * startingKdtDPS, 0);

                elapsedTime += Time.deltaTime;
            }
            else
            {
                matColor.SetColor("_EmissionColor", Color.black);
                Material[] mats = kdtRenderer.sharedMaterials;
                mats[0] = matBase;
                mats[1] = matColor;
                mats[2] = matFace;
                kdtRenderer.sharedMaterials = mats;
                kdtLight.enabled            = true;

                jnkMatColor.SetColor("_EmissionColor", Color.black);
                mats    = jnkRenderer.sharedMaterials;
                mats[0] = jnkMatBase;
                mats[1] = jnkMatFace;
                mats[2] = jnkMatColor;
                jnkRenderer.sharedMaterials = mats;
                jnkLight.enabled            = true;

                wireframeToSolidFx.Play();
                if (multiPlayer)
                {
                    jnkWireframeToSolidFx.Play();
                }

                wireframeToSolidSoundFx.Play();

                elapsedTime = 0f;

                loadingStr = "ACTIVATING COLOR SYSTEM";
                state      = State.ACTIVATING_COLOR;
            }
            break;

        case State.ACTIVATING_COLOR:
            if (elapsedTime < activatingColorDuration)
            {
                float factor     = elapsedTime / activatingColorDuration;
                int   percentage = Mathf.CeilToInt(Mathf.Lerp(startingKDT2Until, activatingColorUntil, factor));

                loadingSlider.value    = percentage;
                percentageSlider.value = percentage;

                percentageBackgroundText.text = percentage + "%";
                percentageForegroundText.text = percentage + "%";

                factor = (elapsedTime - activatingColorStartChangingAt) / (activatingColorDuration - activatingColorStartChangingAt);
                matColor.SetColor("_EmissionColor", Color.Lerp(Color.black, matEmissionFinalColor, factor));
                jnkMatColor.SetColor("_EmissionColor", Color.Lerp(Color.black, jnkMatEmissionFinalColor, factor));

                kdtLight.intensity = Mathf.Lerp(0f, 1f, factor);
                jnkLight.intensity = Mathf.Lerp(0f, 1f, factor);

                elapsedTime += Time.deltaTime;
            }
            else
            {
                matShield.SetColor("_EmissionColor", matEmissionFinalColor);
                kdtShield.SetActive(true);
                kdtAnimator.SetBool("Aiming", true);
                matColor.SetColor("_EmissionColor", matEmissionFinalColor);

                jnkMatShield.SetColor("_EmissionColor", jnkMatEmissionFinalColor);
                jnkShield.SetActive(true);
                jnkAnimator.SetBool("Aiming", true);
                jnkMatColor.SetColor("_EmissionColor", jnkMatEmissionFinalColor);

                kdtLight.intensity = 1f;
                jnkLight.intensity = 1f;

                elapsedTime = 0;

                loadingStr = "STARTING PROGRAM";
                state      = State.STARTING_PROGRAM;
            }
            break;

        case State.STARTING_PROGRAM:
            if (elapsedTime < startingProgramDuration)
            {
                float factor     = elapsedTime / startingProgramDuration;
                int   percentage = Mathf.CeilToInt(Mathf.Lerp(activatingColorUntil, startingProgramUntil, factor));

                loadingSlider.value    = percentage;
                percentageSlider.value = percentage;

                percentageBackgroundText.text = percentage + "%";
                percentageForegroundText.text = percentage + "%";

                kdt.transform.Rotate(0, Time.deltaTime * startingProgramDPS, 0);
                jnk.transform.Rotate(0, Time.deltaTime * startingProgramDPS, 0);

                elapsedTime += Time.deltaTime;
            }
            else
            {
                skipHint.SetActive(false);
                fadeScript.StartFadingToColor(finalFadeTime);
                rsc.audioMng.FadeOutMusic(finalFadeTime);

                elapsedTime = 0;

                state = State.FADING_OUT;
            }
            break;

        case State.FADING_OUT:
            if (!fadeScript.FadingToColor)
            {
                rsc.gameMng.AllowNextSceneActivation();
            }
            break;

        default:
            break;
        }

        if ((InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action2) ||
             InputManager.GetAnyControllerButtonWasPressed(InputControlType.Start)) &&
            state != State.FADING_IN && state != State.FADING_OUT)
        {
            skipHint.SetActive(false);
            rsc.audioMng.FadeOutExternalMusic(alarmSoundFx, 0.5f);
            wireframeToSolidSoundFx.Stop();
            rsc.audioMng.acceptFx.Play();
            fadeScript.StartFadingToColor(finalFadeTime);
            rsc.audioMng.FadeOutMusic(finalFadeTime);
            state = State.FADING_OUT;
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case CreditsState.FADING_IN:
            if (!fadeScript.FadingToClear)
            {
                currentState = CreditsState.WAITING_TITLE;
                waitingTime  = 0;
            }
            break;

        case CreditsState.WAITING_TITLE:
            waitingTime += Time.deltaTime;
            if (waitingTime > initialDelay)
            {
                currentState = CreditsState.CRAWLING;
            }
            break;

        case CreditsState.CRAWLING:
            Vector3 displacement = Vector3.up * Time.deltaTime * crawlingSpeed;
            credits.Translate(displacement);
            copyright.Translate(displacement);

            Vector3 copyScreenPos = Camera.main.WorldToScreenPoint(copyright.transform.position);

            //if (copyright.transform.position.y > Screen.height/2)
            if (copyScreenPos.y > Screen.height / 2)
            {
                currentState = CreditsState.WAITING_COPYRIGHT;
                waitingTime  = 0;
            }
            break;

        case CreditsState.WAITING_COPYRIGHT:
            credits.Translate(Vector3.up * Time.deltaTime * crawlingSpeed);
            waitingTime += Time.deltaTime;
            if (waitingTime > finalDelay)
            {
                loadingScene = SceneManager.LoadSceneAsync("MainMenu");
                loadingScene.allowSceneActivation = false;

                fadeScript.StartFadingToColor(endOfCreditsFadeOutTime);
                rsc.audioMng.FadeOutMusic(endOfCreditsFadeOutTime);
                currentState = CreditsState.FADING_OUT;
            }
            break;

        case CreditsState.FADING_OUT:
            //Continue crawling
            //credits.Translate(Vector3.up * Time.deltaTime * crawlingSpeed);

            if (!fadeScript.FadingToColor)
            {
                loadingScene.allowSceneActivation = true;
                //SceneManager.LoadScene("MainMenu");
            }
            break;
        }


        if (enableB && !buttonPressed && InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action2))
        {
            buttonPressed = true;

            if (currentState != CreditsState.FADING_OUT)
            {
                rsc.audioMng.backFx.Play();
                loadingScene = SceneManager.LoadSceneAsync("MainMenu");
                loadingScene.allowSceneActivation = false;

                fadeScript.StartFadingToColor(forcedFadeOutTime);
                currentState = CreditsState.FADING_OUT;
                rsc.audioMng.FadeOutMusic(forcedFadeOutTime);
            }
        }

        CheckKC();
    }