Assets/Scripts/Overworld/Dialogue/NPC.cs (view raw)
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class NPC : MonoBehaviour
6{
7 private DialogueManager dm;
8 private string colliderName;
9 public Dialogue dialogue;
10
11
12 private void Start()
13 {
14 dm = FindObjectOfType<DialogueManager>();
15 }
16
17
18 private void OnTriggerStay(Collider other)
19 {
20 if(other.gameObject.name == "Player")
21 {
22 if (Input.GetKeyUp("e") && !dm.alreadyTalking)
23 {
24 TriggerDialogue();
25 }
26 }
27
28 }
29
30 public void TriggerDialogue()
31 {
32 dm.StartDialogue(dialogue);
33 }
34}