- Home /
Need help with dialogue system script
I'm sorry if this sounds too amateur. I am working on a Visual Novel project where the game majority mechanic is on its dialogues. I'm working with a friend of mine and we've done several base of the system like changing the name line, dialogue lines, and even character sprites (though only limited to one sprite each time). There are scripts that build this system, one of them is the serializable that fills the lines, it makes a limited space of array, but we don't mind that.
The main problem now is that I unable to insert choice, its flag, and transition to other scene (the script has limit for handling the queue, so I still need to load other screen to make a new queue and manually write it).
Things that I really in dire need to know: 1. making the choice flag as the parent of the dialog queue so each choices goes to each different flag which contains different respond 2. change scene according to choice flag
Here is how the code goes:
The serializable script
[System.Serializable] public class Dialog {
[TextArea(1,2)] public string[] name; [TextArea(1,2)] public string[] chars; [TextArea(3,10)] public string[] sentence; }
The dialogue manager (overview)
//these queue to list all the entries private Queue<string> sentences; private Queue<string> nama; private Queue<string> chara; public Dialog dial; //calling the serializable class void Start() { sentences = new Queue<string>(); nama = new Queue<string>(); chara = new Queue<string>(); StartDialog (dial); } //starting the dialogue system by clearing any previous dialogue public void StartDialog(Dialog Dialog) { nama.Clear (); foreach (string nama in Dialog.name) { namas.Enqueue (nama); } sentences.Clear(); foreach (string sentes in Dialog.sentence) { sentences.Enqueue(sentes); } chara.Clear (); foreach (string chars in Dialog.chars) { chara.Enqueue (chars); } DisplayNextSentes(); } //taking out all line from the queue public void DisplayNextSentes() { //if all sentence, name, and chars line finished, go to end dialogue if(sentences.Count == 0 && nama.Count==0&&chara.Count==0) { EndDialog(); return; } //otherwise dequeue the queue string sentes = sentences.Dequeue(); string nama = nama.Dequeue (); string chars = chara.Dequeue (); } void EndDialog() { //The end dialogue is still in unfinished, it's also the problem but I prioritize the choices first FindObjectOfType<ChangeScene>().changeScene("Prologue2"); }
As you can see, we tried to use the queue method. It works to make basic conversation in general, but when it comes to choices, we don't have the place to put option and locating the lines for every choice chosen.
Thank you in advance!