2 using System.Collections;
3 using System.Collections.Generic;
7 public class Dialogue : MonoBehaviour
9 public GameObject continueButton;
10 public GameObject dialogueBox;
11 public GameObject SpeechBubble;
12 public GameObject mouse;
14 SpeechBubble speechBubble;
16 public Text dialogueText;
18 public string[] sentences;
23 public float typingSpeed;
29 dialogueBox.SetActive(false);
30 continueButton.SetActive(false);
31 SpeechBubble.SetActive(false);
32 speechBubble = SpeechBubble.GetComponent<SpeechBubble>();
37 if (dialogueText.text == sentences[index])
39 continueButton.SetActive(true);
42 if (dialogueText.text != sentences[index])
44 if (Input.GetKeyDown(KeyCode.Return) || Input.GetMouseButtonDown(0))
55 public IEnumerator Type()
57 dialogueBox.SetActive(true);
58 speechBubble.NextSpeaker();
59 SpeechBubble.SetActive(true);
60 foreach (char letter in sentences[index].ToCharArray())
62 dialogueText.text += letter;
63 yield return new WaitForSeconds(typingSpeed);
69 dialogueText.text = sentences[index];
72 public void NextSentence()
74 FindObjectOfType<AudioManager>().Play("click");
75 continueButton.SetActive(false);
78 if (index < sentences.Length - 1)
81 dialogueText.text = "";
82 StartCoroutine(Type());
83 speechBubble.NextSpeaker();
87 dialogueText.text = "";
88 dialogueBox.SetActive(false);
89 SpeechBubble.SetActive(false);
90 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
91 mouse.GetComponent<MouseController>().enabled = true;