finished dialogue villager system

This commit is contained in:
2023-02-08 14:12:06 +01:00
parent 1d363e7741
commit 15407f5f06
2 changed files with 37 additions and 21 deletions

View File

@@ -4,22 +4,22 @@
[
"Oh hello, {player}... You look great! What can I do for you?",
{
"I just wanna talk": true,
"Nevermind!": false
"I just wanna talk": "tipp",
"Nevermind!": "goodbye"
}
],
[
"Hey, {player}! Hope you have fun today! So what do you want?",
{
"What's up": true,
"Nothing": false
"What's up": "tipp",
"Nothing": "goodbye"
}
],
[
"Hi! What's up {player}?",
{
"Can we talk?": true,
"Have a great day!": false
"Can we talk?": "tipp",
"Have a great day!": "goodbye"
}
]
],
@@ -27,24 +27,26 @@
[
"Do you need something else?",
{
"Can you tell me something else?": true,
"No, thanks!": false
"Can you tell me something else?": "tipp",
"No, thanks!": "goodbye"
}
],
[
"So can i help you with something else?",
{
"Tell me a bit more maybe": true,
"I'm good, thank you!": false
"Tell me a bit more maybe": "tipp",
"I'm good, thank you!": "goodbye"
}
]
],
"goodbye": [
[
"Was nice talking to you goodbye!"
"Was nice talking to you goodbye!",
0
],
[
"Have a great day, {player}!"
"Have a great day, {player}!",
0
]
],
"tipp": [

View File

@@ -20,6 +20,8 @@ public partial class dialog_bubble : CanvasLayer
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
GatherDialog("welcome");
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
GatherDialog("message");
Visible = true;
}
@@ -49,7 +51,10 @@ public partial class dialog_bubble : CanvasLayer
{
if (dlgPointer < dlgLines.AsGodotArray().Count)
{
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
GD.Print(dlgLines.AsGodotArray()[dlgPointer].VariantType);
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float && ((float)dlgLines.AsGodotArray()[dlgPointer]) == 0)
CloseDialog();
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
UpdateDialog();
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray());
@@ -61,17 +66,26 @@ public partial class dialog_bubble : CanvasLayer
richText.VisibleCharacters++;
GetNode<Timer>("typewriter_timer").Start();
}
if (dlgPointer > dlgLines.AsGodotArray().Count)
CloseDialog();
{
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
{
GatherDialog("else");
UpdateDialog();
dlgPointer++;
}
else CloseDialog();
}
if (GetNode<PanelContainer>("box/panel_container").Visible == true && GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton() != null)
if (GetNode<PanelContainer>("box/panel_container").Visible == true
&& GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton() != null)
{
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container")
.GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
GetNode<PanelContainer>("box/panel_container").Visible = false;
if (answer.VariantType == Variant.Type.Bool && answer.AsBool())
if (answer.VariantType == Variant.Type.String)
{
GatherDialog("tipp");
GatherDialog(answer.AsString());
UpdateDialog();
}
dlgPointer++;