//--------------------------------------------------------------------- // Typing //--------------------------------------------------------------------- /// <summary> /// The coroutine that handles typing out the sentence. /// </summary> /// <param name="sentence">The sentence to type.</param> /// <param name="autoAdvance">Whether or not to automatically advance the /// dialog after typing has finished.</param> /// <param name="delayBeforeAdvance">How long to delay before advancing the /// dialog, in seconds</param> /// <param name="speed">The speed of typing, in characters per second.</param> private IEnumerator _TypeSentence(string sentence, bool autoAdvance, float delayBeforeAdvance, float speed, bool animateSpeaker) { manager.StillWriting = true; TalkingSound.Play(); if (animateSpeaker) { DialogManager.StartTalking(currentCharacter); } ClearText(); float waitTime = 1 / speed; if (sentence != null) { for (int i = 0; i < sentence.Length; i++) { char c = sentence[i]; TypeCharacter(c); // Waiting for any time after the sentence is finished opens the door // for a race condition. if (i < sentence.Length - 1) { if (DialogManager.Punctuation.ContainsKey(c)) { TalkingSound.Stop(); yield return(new WaitForSeconds(DialogManager.Punctuation[c])); TalkingSound.Play(); } else { yield return(new WaitForSeconds(waitTime)); } } } } TryListDecisions(); if (animateSpeaker) { DialogManager.StopTalking(currentCharacter); } TalkingSound.Stop(); manager.StillWriting = false; if (delayBeforeAdvance > 0) { yield return(new WaitForSeconds(delayBeforeAdvance)); } if (autoAdvance) { DialogManager.ContinueDialog(); } }
//------------------------------------------------------------------------- // Interactible API //------------------------------------------------------------------------- /// <summary> /// What the object should do when interacted with. /// </summary> public override void OnInteract() { if (!interacting) { LoadDialog(); if (Dialog != null) { interacting = true; DialogManager.StartDialog(Dialog.graph); } } else { DialogManager.ContinueDialog(); if (DialogManager.IsDialogFinished()) { interacting = false; // This stops the player from hopping/twitching after the conversation // ends. Input.ResetInputAxes(); } } }
public override void OnInteract() { if (!interacting) { interacting = true; DialogManager.StartDialog(Cutscene); } else { DialogManager.ContinueDialog(); if (DialogManager.IsDialogFinished()) { interacting = false; } } }