diff options
Diffstat (limited to 'Assets/Scripts')
| -rw-r--r-- | Assets/Scripts/Dialogue/DialogueManager.cs | 47 | ||||
| -rw-r--r-- | Assets/Scripts/PauseMenu.cs | 38 | ||||
| -rw-r--r-- | Assets/Scripts/PauseMenu.cs.meta | 11 | ||||
| -rw-r--r-- | Assets/Scripts/Quit.cs | 3 |
4 files changed, 98 insertions, 1 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);
}
}
diff --git a/Assets/Scripts/PauseMenu.cs b/Assets/Scripts/PauseMenu.cs new file mode 100644 index 0000000..284756f --- /dev/null +++ b/Assets/Scripts/PauseMenu.cs @@ -0,0 +1,38 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class PauseMenu : MonoBehaviour
+{
+ public bool lockCursor = true;
+
+ public GameObject panel;
+ private int counter;
+ // Update is called once per frame
+ public void showhidePanel()
+ {
+ counter++;
+ if (counter % 2 == 1)
+ {
+ panel.gameObject.SetActive(true);
+ }
+ else
+ {
+ panel.gameObject.SetActive(false);
+ }
+
+ }
+ void Update()
+ {
+ if (Input.GetKeyDown(KeyCode.Escape))
+ {
+ lockCursor = !lockCursor;
+ showhidePanel();
+
+ }
+
+ Cursor.lockState = lockCursor ? CursorLockMode.Locked : CursorLockMode.None;
+ Cursor.visible = !lockCursor;
+ }
+}
diff --git a/Assets/Scripts/PauseMenu.cs.meta b/Assets/Scripts/PauseMenu.cs.meta new file mode 100644 index 0000000..a95562a --- /dev/null +++ b/Assets/Scripts/PauseMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b6640e7209a07e8c3957684c4915e6ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Quit.cs b/Assets/Scripts/Quit.cs index 40cfc85..089458e 100644 --- a/Assets/Scripts/Quit.cs +++ b/Assets/Scripts/Quit.cs @@ -9,10 +9,11 @@ public class Quit : MonoBehaviour // Update is called once per frame
void Update()
{
+ /*
if (Input.GetKey("escape"))
{
Application.Quit();
}
-
+ */
}
}
|
