summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2020-08-01 17:37:30 +0300
committerJan Tuomi <jan.tuomi@valuemotive.com>2020-08-01 17:37:30 +0300
commit3bcbdb538b69135907caf9e0ecc224a95c133155 (patch)
treeb903785c3bcd3293ff41b3a4ceaa8c8a4d2b68df
parent7456670d9ae8793e2fcab57f4919402f410a0845 (diff)
Work on dialogue
-rw-r--r--scenes/GUI.tscn46
-rw-r--r--scripts/GUI.gd2
-rw-r--r--scripts/Game.gd14
-rw-r--r--scripts/PlayerCharacter.gd10
4 files changed, 60 insertions, 12 deletions
diff --git a/scenes/GUI.tscn b/scenes/GUI.tscn
index 6434d81..b9a55de 100644
--- a/scenes/GUI.tscn
+++ b/scenes/GUI.tscn
@@ -4,6 +4,7 @@
[node name="GUI" type="MarginContainer"]
anchor_right = 1.0
+anchor_bottom = 1.0
margin_left = 20.0
margin_top = 20.0
margin_right = -20.0
@@ -13,10 +14,49 @@ __meta__ = {
"_edit_use_anchors_": false
}
-[node name="VBoxContainer" type="VBoxContainer" parent="."]
+[node name="TopRow" type="VBoxContainer" parent="."]
margin_right = 984.0
-margin_bottom = 14.0
+margin_bottom = 560.0
-[node name="DebugLabel" type="Label" parent="VBoxContainer"]
+[node name="DebugLabel" type="Label" parent="TopRow"]
margin_right = 984.0
margin_bottom = 14.0
+
+[node name="BottomRow" type="VBoxContainer" parent="."]
+margin_right = 984.0
+margin_bottom = 560.0
+alignment = 2
+
+[node name="DialogueBox" type="ColorRect" parent="BottomRow"]
+visible = false
+margin_top = 520.0
+margin_right = 984.0
+margin_bottom = 560.0
+rect_min_size = Vector2( 0, 40 )
+color = Color( 0.631373, 0.270588, 0.960784, 1 )
+
+[node name="Name" type="Label" parent="BottomRow/DialogueBox"]
+anchor_top = -0.00774612
+anchor_bottom = -0.00774612
+margin_left = 18.9
+margin_top = 14.0836
+margin_right = 84.9
+margin_bottom = 28.0836
+rect_pivot_offset = Vector2( 12.2909, 7.63709 )
+text = "Name"
+__meta__ = {
+"_edit_use_anchors_": false
+}
+
+[node name="Text" type="Label" parent="BottomRow/DialogueBox"]
+anchor_top = -0.00774612
+anchor_bottom = -0.00774612
+margin_left = 94.1902
+margin_top = 14.0836
+margin_right = 160.19
+margin_bottom = 28.0836
+rect_pivot_offset = Vector2( 12.2909, 7.63709 )
+text = "Text"
+__meta__ = {
+"_edit_use_anchors_": false
+}
diff --git a/scripts/GUI.gd b/scripts/GUI.gd
index 90a84bb..a4ec573 100644
--- a/scripts/GUI.gd
+++ b/scripts/GUI.gd
@@ -1,7 +1,7 @@
extends MarginContainer
class_name GUI
export (bool) var show_debug = true
-onready var debug_label = $VBoxContainer/DebugLabel
+onready var debug_label = $TopRow/DebugLabel
# Declare member variables here. Examples:
# var a = 2
diff --git a/scripts/Game.gd b/scripts/Game.gd
index e36fdfe..087b5e1 100644
--- a/scripts/Game.gd
+++ b/scripts/Game.gd
@@ -24,7 +24,7 @@ func _on_Level_ready():
update_debug_gui()
func change_level(num: int):
- var new_scene = "res://scenes/Level" + String(num) + ".tscn"
+ var new_scene = "res://scenes/Level%s.tscn" % num
var cur_level = $Level
self.remove_child(cur_level)
@@ -40,3 +40,15 @@ func change_level(num: int):
self.add_child(new_level)
new_level.set_name("Level")
+
+func run_dialogue(other: Node2D):
+ var dialogues: Array = other.get_dialogue()
+ $CanvasLayer/GUI/BottomRow/DialogueBox.set_visible(true)
+ for d in dialogues:
+ var name = d["name"]
+ var body = d["body"]
+ $CanvasLayer/GUI/BottomRow/DialogueBox/Name.set_text(name)
+ $CanvasLayer/GUI/BottomRow/DialogueBox/Text.set_text(body)
+ print("[%s] %s" % [name, body])
+ yield(get_tree().create_timer(1.0), "timeout")
+ $CanvasLayer/GUI/BottomRow/DialogueBox.set_visible(false)
diff --git a/scripts/PlayerCharacter.gd b/scripts/PlayerCharacter.gd
index 3cf4518..4e194d0 100644
--- a/scripts/PlayerCharacter.gd
+++ b/scripts/PlayerCharacter.gd
@@ -39,14 +39,10 @@ func _process(_delta):
$Sprite.set_scale(Vector2(look_dir, 1))
-func run_dialogue(other):
+func run_dialogue(other: Node2D):
dialogue_active_with = other
- var dialogues: Array = other.get_dialogue()
- for d in dialogues:
- var name = d["name"]
- var body = d["body"]
- print("[%s] %s" % [name, body])
-
+ var game: Game = get_tree().get_root().get_node("Game")
+ game.run_dialogue(other)
func _physics_process(_delta):
get_input()