예제 #1
0
        public void Use()
        {
            // In case we want something you can use more than once
            if (isEnabled && (useCount < uses) && (Time.time > timeAvailable))
            {
                timeAvailable = Time.time + timeDisabledAfterUse;
                Debug.Log("using item " + gameObject);
                useCount++;
                if (playSeriesOfAudioClips != null)
                {
                    playSeriesOfAudioClips.PlaySeries();
                    lengthOfAudio     = playSeriesOfAudioClips.GetClipsLength();
                    timeDoneWithAudio = Time.time + lengthOfAudio;
                    //Debug.Log("Playing series");
                }
                else if (useSound != null)
                {
                    audioSource.PlayOneShot(useSound);
                }
                else
                {
                    Debug.Log("No audio");
                }

                // This is the last use
                if (useCount == uses)
                {
                    GetComponent <FlashingIndicator>().DisableFlasher();
                }

                if (triggersNightmareMode)
                {
                    StartCoroutine(TriggerNightmareWithDelay(nightmareTriggerDelay));
                }

                if (triggersDreamMode)
                {
                    backgroundMusicController.PlayMusic(BackgroundMusicController.MusicTypes.normal);
                    nightmareController.SwitchToDream();
                    blockage.SetActive(false);
                    if (spawnsEnemy)
                    {
                        enemy.SetActive(false);
                    }
                }


                // Changing to respawn even at nightmare trigger, because last good location could be harder to get back to the new good location
                // This could end up resulting in repeated deaths though...
                if (triggersNewSpawnPoint)
                {
                    fPSController.RecordNewSpawnPoint();
                }


                originalPosition = transform.position;
                originalScale    = transform.localScale;
                originalRotation = transform.rotation;
                ViewClue();

                StartCoroutine(DelayClueEnable(timeDoneWithAudio));
            }
        }
예제 #2
0
        IEnumerator Level1IntroScript()
        {
            // Disable display and control and start intro audio
            fPSController.InputControl(false);
            fPSController.CameraTarget(animatedTarget);
            GameObject.Find("[UI]/Canvas2/BlackoutPanel").GetComponent <Image>().color = new Color(0, 0, 0, 255);
            //Wait a tiny bit to let things get out of start
            yield return(new WaitForSeconds(0.1f));

            // Disable first clue
            //firstClue.SetActive(false);

            // Line 7-19
            playSeriesOfAudioClips.PlaySeries();

            float clipLength = playSeriesOfAudioClips.GetClipLength(0);

            Debug.Log(Time.time + " waiting for " + clipLength * percentAudioBeforemovement);
            yield return(new WaitForSeconds(clipLength * percentAudioBeforemovement));

            postProcessingObject.GetComponent <constantDOFChanger>().SetDOF(true, 0);
            StartCoroutine(SlowClearBlackout(clipLength * (1 - percentAudioBeforemovement) / 2));
            viewAnimator.SetTrigger("PlayView");


            Debug.Log(Time.time + " waiting for " + clipLength * (1 - percentAudioBeforemovement));
            yield return(new WaitForSeconds(clipLength * (1 - percentAudioBeforemovement)));

            postProcessingObject.GetComponent <constantDOFChanger>().SetDOF(false, 0);

            // Disable input until 2nd clip is done
            // Line 8
            clipLength = playSeriesOfAudioClips.GetClipLength(1);
            yield return(new WaitForSeconds(clipLength));

            // Re-enable display and control
            fPSController.ResetMouseView();
            fPSController.InputControl(true);

            // Line 9
            clipLength = playSeriesOfAudioClips.GetClipLength(2);
            yield return(new WaitForSeconds(clipLength));

            var flickerNightmareTimeOffset = 0.5f;

            // Line 10
            clipLength = playSeriesOfAudioClips.GetClipLength(3) - flickerNightmareTimeOffset;
            yield return(new WaitForSeconds(clipLength));

            // Line 11-13 (time to flicker lights)
            clipLength = playSeriesOfAudioClips.GetClipLength(4) + playSeriesOfAudioClips.GetClipLength(5) + playSeriesOfAudioClips.GetClipLength(6);

            //Full Nightmare here
            nightmareController.SwitchToNightmare(clipLength);

            // Line 14-16
            clipLength += playSeriesOfAudioClips.GetClipLength(7) + playSeriesOfAudioClips.GetClipLength(8) + playSeriesOfAudioClips.GetClipLength(9);
            yield return(new WaitForSeconds(clipLength));

            //Normal again here
            nightmareController.SwitchToDream();

            // Line 17-20
            clipLength = playSeriesOfAudioClips.GetClipLength(10) + playSeriesOfAudioClips.GetClipLength(11) + playSeriesOfAudioClips.GetClipLength(12) + +playSeriesOfAudioClips.GetClipLength(13) + flickerNightmareTimeOffset;
            yield return(new WaitForSeconds(clipLength));

            firstClue.GetComponent <ClueController>().enableClue();
        }