summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Dialogue/DialogueManager.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-08-24 17:18:52 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-08-24 17:18:52 -0400
commitd1c6d296e85646853f7aaa5a07e6d5718fce0072 (patch)
tree77879b3c7a74c2c5c1a7e08f38a691ce9854aab0 /Assets/Scripts/Dialogue/DialogueManager.cs
parent4c8dba7a5ae4338a76e5b8e84438a1bb933e48f6 (diff)
downloadProject-Sandbox-d1c6d296e85646853f7aaa5a07e6d5718fce0072.tar.gz
Project-Sandbox-d1c6d296e85646853f7aaa5a07e6d5718fce0072.tar.bz2
Project-Sandbox-d1c6d296e85646853f7aaa5a07e6d5718fce0072.zip
Pause menu; Dialogue; New font
Diffstat (limited to 'Assets/Scripts/Dialogue/DialogueManager.cs')
-rw-r--r--Assets/Scripts/Dialogue/DialogueManager.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Assets/Scripts/Dialogue/DialogueManager.cs b/Assets/Scripts/Dialogue/DialogueManager.cs
index 056e7d9..4a7b540 100644
--- a/Assets/Scripts/Dialogue/DialogueManager.cs
+++ b/Assets/Scripts/Dialogue/DialogueManager.cs
@@ -1,9 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.UI;
public class DialogueManager : MonoBehaviour
{
+ public Text nameText;
+ public Text dialogueText;
+
+ public Animator animator;
private Queue<string> sentences;
@@ -15,7 +20,49 @@ public class DialogueManager : MonoBehaviour
public void StartDialogue(Dialogue dialogue)
{
+ animator.SetBool("IsOpen", true);
+
Debug.Log("Starting conversation with " + dialogue.name);
+
+ nameText.text = dialogue.name;
+
+ sentences.Clear();
+
+ foreach (string sentence in dialogue.sentences)
+ {
+ sentences.Enqueue(sentence);
+ }
+
+ DisplayNextSentences();
+ }
+
+ public void DisplayNextSentences()
+ {
+ if (sentences.Count == 0)
+ {
+ EndDialogue();
+ return;
+ }
+
+ string sentence = sentences.Dequeue();
+ StopAllCoroutines();
+ StartCoroutine(TypeSentence(sentence));
+ }
+
+ IEnumerator TypeSentence(string sentence)
+ {
+ dialogueText.text = "";
+ foreach (char letter in sentence.ToCharArray())
+ {
+ dialogueText.text += letter;
+ yield return null;
+ }
+ }
+
+ void EndDialogue()
+ {
+ Debug.Log("End of conversation.");
+ animator.SetBool("IsOpen", false);
}
}