@@ -17,13 +17,6 @@ scenes = { | |||||
[node name="CanvasLayer" type="CanvasLayer" parent="."] | [node name="CanvasLayer" type="CanvasLayer" parent="."] | ||||
[node name="UI" type="Control" parent="CanvasLayer"] | |||||
anchor_right = 1.0 | |||||
anchor_bottom = 1.0 | |||||
__meta__ = { | |||||
"_edit_use_anchors_": false | |||||
} | |||||
[node name="HUD" parent="CanvasLayer/UI" instance=ExtResource( 7 )] | |||||
[node name="HUD" parent="CanvasLayer" instance=ExtResource( 7 )] | |||||
[node name="SpeechPanel" parent="CanvasLayer/UI" instance=ExtResource( 6 )] | |||||
[node name="SpeechPanel" parent="CanvasLayer" instance=ExtResource( 6 )] |
@@ -2,9 +2,7 @@ extends BasisInteraction | |||||
class_name TalkInteraction | class_name TalkInteraction | ||||
signal trigger_script | |||||
var yarn_script : Resource | var yarn_script : Resource | ||||
func on_interact(): | func on_interact(): | ||||
emit_signal("trigger_script", yarn_script) | |||||
EventDispatcher.emit_signal("trigger_script", yarn_script) |
@@ -46,3 +46,8 @@ func gold_set(value): | |||||
func gold_get(): | func gold_get(): | ||||
return gold | return gold | ||||
func reset(): | |||||
curHp = maxHp | |||||
emit_signal("curHp_update", curHp) | |||||
gold = 0 | |||||
emit_signal("gold_update", gold) |
@@ -1,12 +1,9 @@ | |||||
extends Area | extends Area | ||||
signal trigger_script | |||||
export var yarnScript : Resource | export var yarnScript : Resource | ||||
func enable(): | func enable(): | ||||
self.connect("body_entered", self, "_on_TriggerArea_body_entered") | self.connect("body_entered", self, "_on_TriggerArea_body_entered") | ||||
func _on_TriggerArea_body_entered(body): | func _on_TriggerArea_body_entered(body): | ||||
print("triggered") | |||||
emit_signal("trigger_script", yarnScript) | |||||
EventDispatcher.emit_signal("trigger_script", yarnScript) |
@@ -4,13 +4,12 @@ export var character_data : Resource | |||||
var interaction_component : BasisInteraction | var interaction_component : BasisInteraction | ||||
func spawn(level): | |||||
func spawn(): | |||||
var inst = character_data.scene.instance() | var inst = character_data.scene.instance() | ||||
inst.name = character_data.name | inst.name = character_data.name | ||||
if character_data.yarn != null: | if character_data.yarn != null: | ||||
interaction_component = TalkInteraction.new() | interaction_component = TalkInteraction.new() | ||||
interaction_component.name = character_data.yarn.resource_name | interaction_component.name = character_data.yarn.resource_name | ||||
interaction_component.yarn_script = character_data.yarn | interaction_component.yarn_script = character_data.yarn | ||||
interaction_component.connect("trigger_script", level, "trigger_script") | |||||
inst.add_child(interaction_component) | inst.add_child(interaction_component) | ||||
add_child(inst) | add_child(inst) |
@@ -1,14 +1,12 @@ | |||||
extends Node | extends Node | ||||
signal all_coins_picked_up | |||||
export var coin_scene : PackedScene | export var coin_scene : PackedScene | ||||
export var all_coins_picked_up_script : Resource | export var all_coins_picked_up_script : Resource | ||||
var coins := -1 | var coins := -1 | ||||
func spawn(level): | |||||
func spawn(): | |||||
if coins < 0: # not spawned yet | if coins < 0: # not spawned yet | ||||
coins = 0 | coins = 0 | ||||
for spawn in get_children(): | for spawn in get_children(): | ||||
@@ -16,9 +14,8 @@ func spawn(level): | |||||
coin.connect("picked_up", self, "on_coin_picked_up") | coin.connect("picked_up", self, "on_coin_picked_up") | ||||
coins += 1 | coins += 1 | ||||
spawn.add_child(coin) | spawn.add_child(coin) | ||||
connect("all_coins_picked_up", level, "trigger_script") | |||||
func on_coin_picked_up(): | func on_coin_picked_up(): | ||||
coins -= 1 | coins -= 1 | ||||
if coins == 0: | if coins == 0: | ||||
emit_signal("all_coins_picked_up", all_coins_picked_up_script) | |||||
EventDispatcher.emit_signal("trigger_script", all_coins_picked_up_script) |
@@ -1,5 +1,6 @@ | |||||
extends Node | extends Node | ||||
var hud : HUD | |||||
var speech_panel : SpeechPanel | var speech_panel : SpeechPanel | ||||
var player_infos := PlayerInfos.new() | var player_infos := PlayerInfos.new() | ||||
@@ -0,0 +1,3 @@ | |||||
extends Node | |||||
signal trigger_script |
@@ -9,11 +9,13 @@ func _ready(): | |||||
yarnRunner.add_command("EnableTrigger", funcref(self, "enable_trigger")) | yarnRunner.add_command("EnableTrigger", funcref(self, "enable_trigger")) | ||||
yarnRunner.add_command("Scene", funcref(self, "scene")) | yarnRunner.add_command("Scene", funcref(self, "scene")) | ||||
for trigger in $Triggers.get_children(): | |||||
trigger.connect("trigger_script", self, "trigger_script") | |||||
EventDispatcher.connect("trigger_script", self, "trigger_script") | |||||
trigger_script(init_yarn_script) | |||||
Controller.hud.show() | |||||
Controller.player_infos.reset() | |||||
trigger_script(init_yarn_script) | |||||
func spawn(args): | func spawn(args): | ||||
yield(get_tree(), "idle_frame") | yield(get_tree(), "idle_frame") | ||||
@@ -23,7 +25,7 @@ func spawn(args): | |||||
var spawner = get_node("Spawners/" + args[0]) | var spawner = get_node("Spawners/" + args[0]) | ||||
if spawner != null and spawner.has_method("spawn"): | if spawner != null and spawner.has_method("spawn"): | ||||
spawner.spawn(self) | |||||
spawner.spawn() | |||||
else: | else: | ||||
print("spawner " + args[0] + " not found or not compatible") | print("spawner " + args[0] + " not found or not compatible") | ||||
@@ -65,3 +67,7 @@ func scene(args): | |||||
print("Request new scene : " + args[0]) | print("Request new scene : " + args[0]) | ||||
emit_signal("request_new_scene", args[0]) | emit_signal("request_new_scene", args[0]) | ||||
func _exit_tree(): | |||||
Controller.hud.hide() | |||||
Controller.speech_panel.hide() |
@@ -16,10 +16,6 @@ func load_scene(scene_key): | |||||
var scene = scenes[scene_key].instance() | var scene = scenes[scene_key].instance() | ||||
scene.connect("request_new_scene", self, "load_scene") | scene.connect("request_new_scene", self, "load_scene") | ||||
$SceneContainer.add_child(scene) | $SceneContainer.add_child(scene) | ||||
if scene_key == "TestGameOver": | |||||
$CanvasLayer/UI.hide() | |||||
else: | |||||
$CanvasLayer/UI.show() | |||||
func wait_signal(args): | func wait_signal(args): | ||||
yield(self, "end") | yield(self, "end") | ||||
@@ -1,5 +1,7 @@ | |||||
extends Control | extends Control | ||||
class_name HUD | |||||
export var healthBar_path : NodePath | export var healthBar_path : NodePath | ||||
onready var healthBar = get_node(healthBar_path) | onready var healthBar = get_node(healthBar_path) | ||||
export var goldText_path : NodePath | export var goldText_path : NodePath | ||||
@@ -27,3 +29,6 @@ func fetch_components(): | |||||
healthBar = get_node("HealthBar") | healthBar = get_node("HealthBar") | ||||
if goldText == null: | if goldText == null: | ||||
goldText = get_node("GoldText") | goldText = get_node("GoldText") | ||||
func _enter_tree(): | |||||
Controller.hud = self |
@@ -29,6 +29,11 @@ _global_script_classes=[ { | |||||
"language": "GDScript", | "language": "GDScript", | ||||
"path": "res://jrpg/scripts/ui/choices_box.gd" | "path": "res://jrpg/scripts/ui/choices_box.gd" | ||||
}, { | }, { | ||||
"base": "Control", | |||||
"class": "HUD", | |||||
"language": "GDScript", | |||||
"path": "res://jrpg/scripts/ui/test_hud.gd" | |||||
}, { | |||||
"base": "KinematicBody", | "base": "KinematicBody", | ||||
"class": "Player", | "class": "Player", | ||||
"language": "GDScript", | "language": "GDScript", | ||||
@@ -84,6 +89,7 @@ _global_script_class_icons={ | |||||
"BasisInteraction": "", | "BasisInteraction": "", | ||||
"CharacterData": "", | "CharacterData": "", | ||||
"ChoicesBox": "", | "ChoicesBox": "", | ||||
"HUD": "", | |||||
"Player": "", | "Player": "", | ||||
"PlayerInfos": "", | "PlayerInfos": "", | ||||
"SpeechPanel": "", | "SpeechPanel": "", | ||||
@@ -105,6 +111,7 @@ config/icon="res://icon.png" | |||||
[autoload] | [autoload] | ||||
Controller="*res://jrpg/scripts/misc/controller.gd" | Controller="*res://jrpg/scripts/misc/controller.gd" | ||||
EventDispatcher="*res://jrpg/scripts/misc/event_dispatcher.gd" | |||||
[editor_plugins] | [editor_plugins] | ||||