randomize begindialogueoptions try
This commit is contained in:
@@ -8,4 +8,4 @@
|
|||||||
[node name="first_world" parent="." instance=ExtResource("2_x8nyb")]
|
[node name="first_world" parent="." instance=ExtResource("2_x8nyb")]
|
||||||
|
|
||||||
[node name="player" parent="." instance=ExtResource("1_p5d84")]
|
[node name="player" parent="." instance=ExtResource("1_p5d84")]
|
||||||
playerName = "PlayerName"
|
playerName = "Yannik"
|
||||||
|
@@ -91,6 +91,7 @@ height = 45.968
|
|||||||
[node name="player" type="CharacterBody2D"]
|
[node name="player" type="CharacterBody2D"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
|
position = Vector2(-1, 0)
|
||||||
script = ExtResource("1_qehox")
|
script = ExtResource("1_qehox")
|
||||||
|
|
||||||
[node name="rotation_center" type="Marker2D" parent="."]
|
[node name="rotation_center" type="Marker2D" parent="."]
|
||||||
|
@@ -28,8 +28,10 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
public void WelcomeDialog()
|
public void WelcomeDialog()
|
||||||
{
|
{
|
||||||
string[] welcomeText = parsedDlg.AsGodotDictionary()["welcome"].AsStringArray();
|
string[] welcomeText = parsedDlg.AsGodotDictionary()["welcome"].AsStringArray();
|
||||||
|
Godot.Collections.Dictionary playerbeginoptions = parsedDlg.AsGodotDictionary()["playerbeginoptions"].AsGodotDictionary();
|
||||||
|
GD.Randomize();
|
||||||
dlgLines.Add(welcomeText[GD.Randi() % welcomeText.Length]);
|
dlgLines.Add(welcomeText[GD.Randi() % welcomeText.Length]);
|
||||||
MakeAnswerBox(new string[] { "talk", "go away" });
|
MakeAnswerBox(new string[] { playerbeginoptions["talk"].AsStringArray()[GD.Randi() % playerbeginoptions["talk"].AsStringArray().Length], playerbeginoptions["goaway"].AsStringArray()[GD.Randi() % playerbeginoptions["goaway"].AsStringArray().Length] });
|
||||||
}
|
}
|
||||||
public void CloseDialog()
|
public void CloseDialog()
|
||||||
{
|
{
|
||||||
@@ -61,7 +63,7 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
if (dlgPointer > dlgLines.Count)
|
if (dlgPointer > dlgLines.Count)
|
||||||
CloseDialog();
|
CloseDialog();
|
||||||
|
|
||||||
//AnswerBox wait for typewrite effect to finish
|
//AnswerBox wait for typewrite effect to finish (garbage code)
|
||||||
GetNode<PanelContainer>("box/panel_container").Visible = richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length == richText.VisibleCharacters && GetNode("box/panel_container/margin_container/v_box_container").GetChildCount() == dialogOptionsLength;
|
GetNode<PanelContainer>("box/panel_container").Visible = richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length == richText.VisibleCharacters && GetNode("box/panel_container/margin_container/v_box_container").GetChildCount() == dialogOptionsLength;
|
||||||
}
|
}
|
||||||
public void MakeAnswerBox(string[] dialogOptions)
|
public void MakeAnswerBox(string[] dialogOptions)
|
||||||
@@ -70,6 +72,7 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
var parent = GetNode("box/panel_container/margin_container/v_box_container");
|
var parent = GetNode("box/panel_container/margin_container/v_box_container");
|
||||||
for (int i = 0; parent.GetChildCount() < dialogOptions.Length; i++)
|
for (int i = 0; parent.GetChildCount() < dialogOptions.Length; i++)
|
||||||
{
|
{
|
||||||
|
//remove button nodes for randomizing
|
||||||
parent.AddChild(button.Instantiate());
|
parent.AddChild(button.Instantiate());
|
||||||
parent.GetChild<Button>(i).Text = dialogOptions[i];
|
parent.GetChild<Button>(i).Text = dialogOptions[i];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user