1 using System.Collections;
2 using System.Collections.Generic;
6 public class Dialogue : MonoBehaviour
8 public GameObject continueButton;
9 public GameObject dialogueBox;
10 public GameObject SpeechBubble;
11 public GameObject mouse;
13 SpeechBubble speechBubble;
15 public Text dialogueText;
17 public string[] sentences;
22 public float typingSpeed;
26 dialogueBox.SetActive(false);
27 continueButton.SetActive(false);
28 SpeechBubble.SetActive(false);
29 speechBubble = SpeechBubble.GetComponent<SpeechBubble>();
34 if (dialogueText.text == sentences[index])
36 continueButton.SetActive(true);
40 public IEnumerator Type()
42 dialogueBox.SetActive(true);
43 speechBubble.NextSpeaker();
44 SpeechBubble.SetActive(true);
45 foreach (char letter in sentences[index].ToCharArray())
47 dialogueText.text += letter;
48 yield return new WaitForSeconds(typingSpeed);
52 public void NextSentence()
54 FindObjectOfType<AudioManager>().Play("click");
55 continueButton.SetActive(false);
57 if (index < sentences.Length - 1)
60 dialogueText.text = "";
61 StartCoroutine(Type());
62 speechBubble.NextSpeaker();
66 dialogueText.text = "";
67 dialogueBox.SetActive(false);
68 SpeechBubble.SetActive(false);
69 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
70 mouse.GetComponent<MouseController>().enabled = true;