2 using System.Collections;
3 using System.Collections.Generic;
7 public class Dialogue : MonoBehaviour
9 public GameObject continueButton;
10 public GameObject skipButton;
11 public GameObject dialogueBox;
12 public GameObject SpeechBubble;
13 public GameObject mouse;
15 SpeechBubble speechBubble;
17 public Text dialogueText;
19 public string[] sentences;
24 public float typingSpeed;
28 dialogueBox.SetActive(false);
29 continueButton.SetActive(false);
30 skipButton.SetActive(false);
31 SpeechBubble.SetActive(false);
32 speechBubble = SpeechBubble.GetComponent<SpeechBubble>();
37 if (dialogueText.text == sentences[index])
39 continueButton.SetActive(true);
40 skipButton.SetActive(true);
44 public IEnumerator Type()
46 dialogueBox.SetActive(true);
47 skipButton.SetActive(true);
48 speechBubble.NextSpeaker();
49 SpeechBubble.SetActive(true);
50 foreach (char letter in sentences[index].ToCharArray())
52 dialogueText.text += letter;
53 yield return new WaitForSeconds(typingSpeed);
57 public void NextSentence()
59 FindObjectOfType<AudioManager>().Play("click");
60 continueButton.SetActive(false);
62 if (index < sentences.Length - 1)
65 dialogueText.text = "";
66 StartCoroutine(Type());
67 speechBubble.NextSpeaker();
71 dialogueText.text = "";
72 dialogueBox.SetActive(false);
73 SpeechBubble.SetActive(false);
74 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
75 mouse.GetComponent<MouseController>().enabled = true;
81 dialogueText.text = "";
82 dialogueBox.SetActive(false);
83 SpeechBubble.SetActive(false);
84 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
85 mouse.GetComponent<MouseController>().enabled = true;