init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
44
Assets/Tools/DialogueSystem/DialogueSystem.cs
Normal file
44
Assets/Tools/DialogueSystem/DialogueSystem.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DialogueSystem : MonoBehaviour{
|
||||
|
||||
public TextMeshProUGUI nameText;
|
||||
public TextMeshProUGUI dialogueText;
|
||||
public TMP_Animated dialogue;
|
||||
|
||||
public Queue<string> sentences;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
sentences = new Queue<string>();
|
||||
}
|
||||
|
||||
public void StartDialogue(Dialogue dialogue){
|
||||
nameText.text = dialogue.characterName;
|
||||
|
||||
sentences.Clear();
|
||||
|
||||
foreach(string sentence in dialogue.sentences){
|
||||
sentences.Enqueue(sentence);
|
||||
}
|
||||
|
||||
DisplayNextSentence();
|
||||
}
|
||||
|
||||
public void DisplayNextSentence(){
|
||||
if(sentences.Count == 0){
|
||||
EndDialogue();
|
||||
return;
|
||||
}
|
||||
|
||||
string sentence = sentences.Dequeue();
|
||||
dialogue.ReadText(sentence);
|
||||
}
|
||||
|
||||
void EndDialogue(){
|
||||
Debug.Log("End of conversation.");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue