answerbox basic functional
This commit is contained in:
@@ -19,6 +19,7 @@ position = Vector2(0, 20.625)
|
|||||||
shape = SubResource("RectangleShape2D_pchpi")
|
shape = SubResource("RectangleShape2D_pchpi")
|
||||||
|
|
||||||
[node name="dialog_trigger_area" parent="." instance=ExtResource("2_blpmd")]
|
[node name="dialog_trigger_area" parent="." instance=ExtResource("2_blpmd")]
|
||||||
|
position = Vector2(3, 0)
|
||||||
file = "res://assets/lang/en/dialogue/npcs/villager_normal.json"
|
file = "res://assets/lang/en/dialogue/npcs/villager_normal.json"
|
||||||
title = "Debug cupcake"
|
title = "Debug cupcake"
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
|
|
||||||
public void GatherDialog(string key)
|
public void GatherDialog(string key)
|
||||||
{
|
{
|
||||||
|
dlgPointer = 0;
|
||||||
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
|
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
|
||||||
if (dlgLines.VariantType == Variant.Type.Array)
|
if (dlgLines.VariantType == Variant.Type.Array)
|
||||||
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)];
|
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)];
|
||||||
@@ -49,15 +50,9 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
||||||
{
|
{
|
||||||
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
|
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
|
||||||
{
|
UpdateDialog();
|
||||||
richText.Text = dlgLines.AsGodotArray()[dlgPointer].ToString();
|
|
||||||
richText.VisibleCharacters = 0;
|
|
||||||
GetNode<Timer>("typewriter_timer").Start();
|
|
||||||
}
|
|
||||||
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
|
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
|
||||||
{
|
|
||||||
MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray());
|
MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dlgPointer++;
|
dlgPointer++;
|
||||||
}
|
}
|
||||||
@@ -71,7 +66,22 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
CloseDialog();
|
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)
|
||||||
GD.Print(GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton());
|
{
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
GatherDialog("tipp");
|
||||||
|
UpdateDialog();
|
||||||
|
}
|
||||||
|
dlgPointer++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateDialog()
|
||||||
|
{
|
||||||
|
richText.Text = dlgLines.AsGodotArray()[dlgPointer].ToString();
|
||||||
|
richText.VisibleCharacters = 0;
|
||||||
|
GetNode<Timer>("typewriter_timer").Start();
|
||||||
}
|
}
|
||||||
public void MakeAnswerBox(string[] dialogOptions)
|
public void MakeAnswerBox(string[] dialogOptions)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user