Пример #1
0
 void OnCollisionExit(Collision other)
 {
     SoundEffects[] sfx = other.gameObject.GetComponents <SoundEffects>();
     foreach (SoundEffects s in sfx)
     {
         if (s.loop)
         {
             SfxManager.StopLoop(s.id);
         }
     }
 }
Пример #2
0
    private IEnumerator FadeLoops(int a, int b, float time)
    {
        float startTime = Time.time;

        while (Time.time < startTime + time)
        {
            float t = (Time.time - startTime) / time;
            SfxManager.PlayLoop(a, Mathf.Lerp(1, 0, t));
            SfxManager.PlayLoop(b, Mathf.Lerp(0, 1, t));
            yield return(null);
        }
        SfxManager.PlayLoop(b);
        SfxManager.StopLoop(a);
    }
Пример #3
0
    private IEnumerator MoveFloorsRoutine(int start, int end)
    {
        if (doorPosition > 0)
        {
            if (floorsVisited == 0)
            {
                yield return(StartCoroutine(MoveDoorsRoutine(doorPosition, 0, waitTime: 3)));
            }
            else
            {
                yield return(StartCoroutine(MoveDoorsRoutine(doorPosition, doorPosition - 0.1f, waitTime: 1)));

                if (doorPosition > 0)
                {
                    moveFloorsRoutine = null;
                    yield break;
                }
            }
        }

        yield return(new WaitForSeconds(1));

        SfxManager.PlayLoop(1);

        int floorProgress = 0;

        string directionArrow = (start < end) ? "v " : "^ ";

        floorDisplay.text = directionArrow + (floorPosition == 0 ? "1F" : "B" + floorPosition);

        while ((start < end) ? floorPosition <end : floorPosition> end)
        {
            if (floorsVisited == 0 && floorProgress == 2) // Elevator crash cutscene
            {
                yield return(new WaitForSeconds(elevatorFloorInterval * 0.5f));

                SfxManager.StopLoop(0);
                SfxManager.StopLoop(1);

                SfxManager.PlaySfx(4);
                CameraShake.ShakeCamera(0.3f, 5); // Shake Camera for 5 seconds

                for (int i = 0; i < 5; i++)       // Lights flash for a bit
                {
                    lightControl.AllLightsOff();
                    floorDisplay.gameObject.SetActive(false);
                    yield return(new WaitForSeconds(0.15f));

                    lightControl.AllLightsOn();
                    floorDisplay.gameObject.SetActive(true);
                    yield return(new WaitForSeconds(0.1f));
                }

                // Lights turn off
                lightControl.AllLightsOff();
                floorDisplay.gameObject.SetActive(false);
                yield return(new WaitForSeconds(5));

                SfxManager.PlaySfx(19); // Evacuation announcement
                yield return(new WaitForSeconds(20));

                SfxManager.PlaySfx(5); // Lights turn on sound
                yield return(new WaitForSeconds(1));

                // Lights back on
                lightControl.AllLightsOn();
                floorDisplay.gameObject.SetActive(true);
                yield return(new WaitForSeconds(2));

                //shepardTone.SetActive(true);
                SfxManager.PlayLoop(0);
                SfxManager.PlayLoop(1, 0.1f);
                SfxManager.PlayLoop(3);

                yield return(new WaitForSeconds(elevatorFloorInterval * 0.5f));
            }
            else if (floorPosition == 4 && end == 5) // Last cutscene part 1
            {
                onRouteToSecret = true;
                StartCoroutine(AnimateFloorDisplay());

                yield return(new WaitForSeconds(10));

                onRouteToSecret = false;
            }
            else
            {
                yield return(new WaitForSeconds(elevatorFloorInterval * 0.5f));

                SfxManager.StopLoop(4);
            }

            floorProgress++;

            SfxManager.PlaySfx(1);

            floorPosition += (start < end) ? 1 : -1;

            floorDisplay.text = directionArrow + "B" + floorPosition;
        }

        floorDisplay.text = floorPosition == 0 ? "  1F" : "  B" + floorPosition;

        if (floorPosition == 5)
        {
            floorDisplay.text = "EXIT";
        }

        if (floorPosition == 0)
        {
            SfxManager.PlayLoop(4);
        }

        SfxManager.StopLoop(1);

        yield return(new WaitForSeconds(1));

        if (floorsVisited == 1) //Floor 2 Cut Scene
        {
            floor1.SetActive(false);
            floor2.transform.position = Vector3.zero;
            floor2.SetActive(true);

            yield return(StartCoroutine(MoveDoorsRoutine(0, 1)));

            SfxManager.PlaySfx(9);

            yield return(new WaitForSeconds(2));

            SfxManager.PlaySfx(10);

            Coroutine flickerLightsRoutine = StartCoroutine(FlickerElevatorLights());

            yield return(new WaitForSeconds(8));

            canCloseDoors = true;

            yield return(new WaitForSeconds(8));

            canCloseDoors = false;

            // Play banging effect/cutscene
            yield return(StartCoroutine(MoveDoorsRoutine(doorPosition, 0)));

            StopCoroutine(flickerLightsRoutine);

            lightControl.AllLightsOn();
            floor2.SetActive(false);

            SfxManager.PlaySfx(11);
            CameraShake.ShakeCamera(0.3f, 2);
            SfxManager.PlaySfx(25);

            yield return(new WaitForSeconds(2));

            SfxManager.PlaySfx(12);
            CameraShake.ShakeCamera(0.3f, 2);
            SfxManager.PlaySfx(23);

            yield return(new WaitForSeconds(1));

            //SfxManager.PlaySfx(13); // Intercom message

            StartCoroutine(OpenCabinetDoor());
            passCodeDisplay.text = "---";

            yield return(new WaitForSeconds(10));

            StartCoroutine(MonsterHit());
        }
        else if (floorsVisited == 2) //Floor 3 Cutscene
        {
            floor2.SetActive(false);
            floor3.transform.position = Vector3.zero;
            floor3.SetActive(true);

            yield return(StartCoroutine(MoveDoorsRoutine(0, 1)));

            yield return(new WaitForSeconds(3));

            cameraFade.CutToBlack();

            yield return(new WaitForSeconds(5));

            sfxBehindYou.SetActive(true);

            yield return(new WaitForSeconds(1));

            cameraFade.CutFromBlack();

            StartCoroutine(JumpScareScene());
        }
        else
        {
            yield return(StartCoroutine(MoveDoorsRoutine(0, 1)));
        }

        floorsVisited++;
        moveFloorsRoutine = null;
    }