Created
January 29, 2023 18:34
-
-
Save valkyrienyanko/5ece685df883492f15f5472f669c6909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void NextDialogue(bool firstDialogue) | |
{ | |
// Hide the choices before each new dialogue is shown | |
HideChoices(); | |
// Get the current conversation | |
var conversation = Conversations[CurConversation]; | |
// Are we at the end of the conversation? | |
if (CurDialogIndex >= conversation.Count) | |
{ | |
// Close all the dialogue UIs | |
CurDialogIndex = 0; | |
Destroy(); | |
return; | |
} | |
// Get the current dialog in the conversation | |
var dialog = conversation[CurDialogIndex++]; | |
// Display the dialogue | |
Text(dialog.Name, dialog.Text, firstDialogue ? 0.5 : 0); | |
// Are there choices to this dialogue? | |
if (dialog.Choices != null) | |
{ | |
// There are choices, lets show them | |
SectionChoices.Show(); | |
// Showing all choices that were defined | |
for (int i = 0; i < BtnChoices.Length; i++) | |
if (dialog.Choices.ElementAtOrDefault(i) != default(Choice)) | |
{ | |
var btn = BtnChoices[i]; | |
btn.Show(); | |
// Lets do something when we click on a choice | |
void onPressed() | |
{ | |
// Unsubscribe as soon as we click on a choice to prepare it for later | |
btn.Pressed -= onPressed; | |
var dialogues = dialog.Choices[i].Dialogues; | |
// Does this choice lead to additional dialogues? | |
if (dialogues != null) | |
{ | |
// ??? | |
} | |
} | |
btn.Pressed += onPressed; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment