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 StopCoroutine(Type());
82 FindObjectOfType<AudioManager>().Play("click");
83 skipButton.SetActive(false);
85 if (index < sentences.Length - 1)
88 dialogueText.text = "";
89 dialogueText.text = sentences[index];
90 speechBubble.NextSpeaker();
94 dialogueText.text = "";
95 dialogueBox.SetActive(false);
96 SpeechBubble.SetActive(false);
97 mouse.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
98 mouse.GetComponent<MouseController>().enabled = true;