-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogueManager.cs
More file actions
58 lines (47 loc) · 1.46 KB
/
DialogueManager.cs
File metadata and controls
58 lines (47 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using TMPro;
using UnityEngine;
public class DialogueManager : MonoBehaviour
{
[Header("References")]
public NPCFinder npcFinder;
public TMP_Text dialogueBox;
public GameObject inputIndication;
public TMP_Text npcName;
[SerializeField] private GameObject dialogueUI;
[HideInInspector] public int dialogueOrder = -1;
[Header("Checks")]
public bool isWithinRadius;
public bool isTalking;
private void Start() => dialogueUI.SetActive(false);
private void UpdateText() => dialogueBox.text = npcFinder.GetNpcName.npc.AllDialogue[npcFinder.firstNPCDialogue].NpcDialogue[dialogueOrder].NpcDialogue;
public void OnStartConversation()
{
isTalking = true;
dialogueUI.SetActive(true);
npcName.text = npcFinder.GetNpcName.npc.name;
Next();
}
private void Next()
{
dialogueOrder++;
if(dialogueOrder >= npcFinder.GetNpcName.npc.AllDialogue[npcFinder.firstNPCDialogue].NpcDialogue.Count)
{
OnEndConversation();
return;
}
UpdateText();
}
public void Previous()
{
dialogueOrder--;
if(dialogueOrder < 0) dialogueOrder = 0;
UpdateText();
}
public void OnEndConversation()
{
isTalking = false;
dialogueUI.SetActive(false);
Reset();
}
private void Reset() => dialogueOrder = -1;
}