]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Dialogue/DialogueTrigger.cs
Stamping v0.3
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Dialogue / DialogueTrigger.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class DialogueTrigger : MonoBehaviour
6 {
7     [SerializeField]
8     GameObject DialogueManager;
9
10     Dialogue dialogue;
11
12     void Start()
13     {
14         dialogue = DialogueManager.GetComponent<Dialogue>();
15     }
16
17     private void OnTriggerEnter2D(Collider2D collision)
18     {
19         if(collision.gameObject.CompareTag("Player"))
20         {
21             StartCoroutine(dialogue.Type());
22             collision.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
23             collision.gameObject.GetComponent<MouseController>().enabled = false;
24             GetComponent<BoxCollider2D>().enabled = false;
25         }
26     }
27
28     void Update()
29     {
30         if (dialogue.skip)
31         {
32             StopCoroutine(dialogue.Type());
33             dialogue.Skip();
34             dialogue.skip = false;
35         }
36     }
37 }