summaryrefslogtreecommitdiff
path: root/Assets/Scripts
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
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')
-rw-r--r--Assets/Scripts/Dialogue/DialogueManager.cs47
-rw-r--r--Assets/Scripts/PauseMenu.cs38
-rw-r--r--Assets/Scripts/PauseMenu.cs.meta11
-rw-r--r--Assets/Scripts/Quit.cs3
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();
}
-
+ */
}
}