diff --git a/scenes/player.tscn b/scenes/player.tscn index f2e2bbf..6cdc1b8 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -16,6 +16,7 @@ radius = 21.0 height = 66.0 [node name="player" type="CharacterBody2D"] +process_mode = 1 script = ExtResource("1_qehox") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/src/scene-scripts/dialog_trigger_area.cs b/src/scene-scripts/dialog_trigger_area.cs index ffdeec3..fc81323 100644 --- a/src/scene-scripts/dialog_trigger_area.cs +++ b/src/scene-scripts/dialog_trigger_area.cs @@ -1,5 +1,4 @@ using Godot; -using Godot.Collections; using System; public partial class dialog_trigger_area : Area2D @@ -8,21 +7,8 @@ public partial class dialog_trigger_area : Area2D string dialogFile; [Export] string dialogTitle; - public string printedDialog; public void OnInteraction(string playerName) { - string currentKey = "randomWelcomeText"; - using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); - string text = file.GetAsText(); - - var jsonFile = JSON.ParseString(text); - Dictionary allDialog = (Dictionary)jsonFile; - if (currentKey.BeginsWith("random")) { - string[] dialogPart = allDialog[currentKey].AsStringArray(); - printedDialog = dialogPart[GD.Randi() % dialogPart.Length]; - } else printedDialog = allDialog[currentKey].AsString(); - printedDialog = String.Format(printedDialog, playerName); - - GetNode("/root/main/dialog_bubble").Call("ImportString",dialogTitle, printedDialog); + GetNode("/root/main/dialog_bubble").Call("ImportString",dialogTitle,dialogFile,playerName); } } diff --git a/src/scene-scripts/gui/dialog_bubble.cs b/src/scene-scripts/gui/dialog_bubble.cs index d0c0315..7c2fd6f 100644 --- a/src/scene-scripts/gui/dialog_bubble.cs +++ b/src/scene-scripts/gui/dialog_bubble.cs @@ -1,12 +1,47 @@ using Godot; +using Godot.Collections; using System; public partial class dialog_bubble : CanvasLayer { - public void ImportString(string dialogTitle, string printedDialog) + public string printedDialog; + public int debugCounter; + public void ImportString(string dialogTitle, string dialogFile, string playerName) { - Visible = !Visible; + Visible = true; + GD.Print("test"); + GetNode("/root/main/player").Call("ChangeProcess",false); + string currentKey = "randomWelcomeText"; + using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); + string text = file.GetAsText(); + + var jsonFile = JSON.ParseString(text); + Dictionary allDialog = (Dictionary)jsonFile; + if (currentKey.BeginsWith("random")) + { + string[] dialogPart = allDialog[currentKey].AsStringArray(); + printedDialog = dialogPart[GD.Randi() % dialogPart.Length]; + } + else printedDialog = allDialog[currentKey].AsString(); + printedDialog = String.Format(printedDialog, playerName); GetNode