added villager introduction and actual EventIDs
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"dialogType": "villager",
|
"dialogType": "villager",
|
||||||
|
"intro": [
|
||||||
|
[
|
||||||
|
"Hello i'm {title}. Your name must be {player}!",
|
||||||
|
1
|
||||||
|
]
|
||||||
|
],
|
||||||
"welcome": [
|
"welcome": [
|
||||||
[
|
[
|
||||||
"Oh hello, {player}... You look great! What can I do for you?",
|
"Oh hello, {player}... You look great! What can I do for you?",
|
||||||
|
@@ -7,6 +7,8 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
public Variant dlgLines;
|
public Variant dlgLines;
|
||||||
public int dlgPointer = 0;
|
public int dlgPointer = 0;
|
||||||
public RichTextLabel richText;
|
public RichTextLabel richText;
|
||||||
|
public string name;
|
||||||
|
public Area2D triggerArea;
|
||||||
|
|
||||||
/*TODO:
|
/*TODO:
|
||||||
- Dont repeat the same randomized dialogue after you get asked do you need something "else"
|
- Dont repeat the same randomized dialogue after you get asked do you need something "else"
|
||||||
@@ -18,14 +20,22 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
richText = GetNode<RichTextLabel>("box/rich_text_label");
|
richText = GetNode<RichTextLabel>("box/rich_text_label");
|
||||||
}
|
}
|
||||||
public void GetDialog(string file, string title, Variant actor, string playerName)
|
public void GetDialog(string file, string title, Area2D actor, string playerName, bool introducedVillager)
|
||||||
{
|
{
|
||||||
|
triggerArea = actor;
|
||||||
|
name = title;
|
||||||
playerName = "[color=blue]" + playerName + "[/color]";
|
playerName = "[color=blue]" + playerName + "[/color]";
|
||||||
parsedDlg = Json.ParseString(FileAccess.Open(file, FileAccess.ModeFlags.Read).GetAsText().Replace("{player}", playerName));
|
parsedDlg = Json.ParseString(FileAccess.Open(file, FileAccess.ModeFlags.Read).GetAsText().Replace("{player}", playerName).Replace("{title}", title));
|
||||||
GetNode<Label>("box/name_label").Text = title;
|
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
|
||||||
|
GetNode<Label>("box/name_label").Text = title;
|
||||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
|
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
|
||||||
|
|
||||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
||||||
GatherDialog("welcome");
|
if (introducedVillager)
|
||||||
|
GatherDialog("welcome");
|
||||||
|
else
|
||||||
|
GatherDialog("intro");
|
||||||
|
|
||||||
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
|
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
|
||||||
GatherDialog("message");
|
GatherDialog("message");
|
||||||
Visible = true;
|
Visible = true;
|
||||||
@@ -57,8 +67,7 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
||||||
{
|
{
|
||||||
GD.Print(dlgLines.AsGodotArray()[dlgPointer].VariantType);
|
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float)
|
||||||
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float && ((float)dlgLines.AsGodotArray()[dlgPointer]) == 0)
|
|
||||||
InDialogEvents((int)dlgLines.AsGodotArray()[dlgPointer]);
|
InDialogEvents((int)dlgLines.AsGodotArray()[dlgPointer]);
|
||||||
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
|
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
@@ -123,6 +132,13 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
case 0:
|
case 0:
|
||||||
CloseDialog();
|
CloseDialog();
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
GetNode<Label>("box/name_label").Text = name;
|
||||||
|
triggerArea.Set("introducedVillager", true);
|
||||||
|
GatherDialog("welcome");
|
||||||
|
UpdateDialog();
|
||||||
|
dlgPointer++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,9 +5,5 @@ public partial class dialog_trigger_area : Area2D
|
|||||||
{
|
{
|
||||||
[Export(PropertyHint.File, "*json")] string file;
|
[Export(PropertyHint.File, "*json")] string file;
|
||||||
[Export] string title;
|
[Export] string title;
|
||||||
public Variant actor;
|
[Export] bool introducedVillager;
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
actor = GetParent(); //must be the scene's root node
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,8 @@ public partial class player : CharacterBody2D
|
|||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding() && allowMovement)
|
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding() && allowMovement)
|
||||||
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("file").AsString(), dialogRayCast.GetCollider().Get("title").AsString(), dialogRayCast.GetCollider().Get("actor"), playerName);
|
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("file").AsString(), dialogRayCast.GetCollider().Get("title").AsString(),
|
||||||
|
(Area2D)dialogRayCast.GetCollider(), playerName, dialogRayCast.GetCollider().Get("introducedVillager").AsBool());
|
||||||
|
|
||||||
//animation system (with controller support wich cant get normalized vector)
|
//animation system (with controller support wich cant get normalized vector)
|
||||||
if (allowMovement == false)
|
if (allowMovement == false)
|
||||||
|
Reference in New Issue
Block a user