/// <summary> /// Plays a <see cref="Narration"/> with the given text and exit key /// and invokes a callback delegate once the narration exits. /// </summary> public void Narrate(string text, KeyCode exitKey, NarrationCallback callback) { var narration = new Narration { Text = text, ExitKey = exitKey }; Narrate(narration, callback); }
private void Exit() { GameManager.Instance.InGamePause(false); if (_callback != null) { _callback(); _callback = null; } enabled = false; }
private void ClearCallback() { _narrationCallback = null; }
/// <summary> /// Plays the given <see cref="Narration"/> and invokes a callback /// delegate once the narration exits. /// </summary> public void Narrate(Narration narration, NarrationCallback callback) { _callback = callback; Narrate(narration); }
/// <summary> /// Handles the current game progress by e.g. spawning enemies, triggering narrations /// or showing items. /// </summary> /// <param name="checkpointLoaded">Whether acting was triggered by a checkpoint load or not.</param> private void ActOnProgress(bool checkpointLoaded = false) { switch (CurrentProgress) { case GameProgress.Intro: GameManager.Instance.InGamePause(true); AudioManager.Instance.PlayEerieMusic(); Intro.Play(); break; case GameProgress.Beginning: AudioManager.Instance.PlayForestAmbient(); if (checkpointLoaded) { AudioManager.Instance.PlayEerieMusic(); } _narrationCallback += PlayBeginningAudio; _narrationCallback += ClearCallback; Narrator.Instance.Narrate(_beginning, KeyCode.Space, _narrationCallback); break; case GameProgress.FirstEnemyFound: AudioManager.Instance.StopBackgroundMusic(0.3f); if (checkpointLoaded) { OpenCutsceneDoor(); } _narrationCallback += AudioManager.Instance.PlayChaseMusic; _narrationCallback += ClearCallback; Narrator.Instance.Narrate(_firstEnemyFound, KeyCode.Space, _narrationCallback); DisableOutDoors(true); break; case GameProgress.FirstEnemyKilled: AudioManager.Instance.StopBackgroundMusic(); Invoke("EndFirstEnemyKilledProgress", 4.0f); break; case GameProgress.OutdoorAvailable: AudioManager.Instance.PlayAmbientLoop(); Narrator.Instance.Narrate(_flashlightFound, KeyCode.Space); ResetDropZone(); if (checkpointLoaded) { EnemyManager.Instance.ChangeAi(AiBehaviour.Patrolling); } else { SpawnEnemies(); } break; case GameProgress.CarFound: Narrator.Instance.Narrate(_carFound, KeyCode.Space); break; case GameProgress.AllCarPartsFound: AudioManager.Instance.PlayAmbientLoop(); Narrator.Instance.Narrate(_allCarPartsFound, KeyCode.Space); ResetFixer(); break; } SetItemAvailability(); Debug.Log("Acted on progress: " + CurrentProgress); }