From c68a84f99b7ebc311a1eb96404db834243084d58 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 <51231053+CactiChameleon9@users.noreply.github.com> Date: Thu, 24 Mar 2022 17:20:11 +0000 Subject: [PATCH] Make the choosing of moves do something(new move_selected method) --- src/classes/Unit.gd | 13 +++++++++++++ src/classes/Unit.tscn | 3 ++- src/nodes/UI/UnitPopup.gd | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/classes/Unit.gd b/src/classes/Unit.gd index 31c5221..3e95ed7 100644 --- a/src/classes/Unit.gd +++ b/src/classes/Unit.gd @@ -115,3 +115,16 @@ func _physics_process(delta: float) -> void: emit_signal("turn_completed") _has_sent_turn_completed = true + +func _on_move_selected(move_num) -> void: + + #get move properties TODO + var target_move = get_node(("Move" + move_num)) + + var move_name = target_move.getName() + var move_damage = target_move.getDamage() + var move_points = target_move.getPoints() + var move_pattern = target_move.getPattern() + + #run attack function + attack(move_damage, move_points, move_pattern) diff --git a/src/classes/Unit.tscn b/src/classes/Unit.tscn index dcc4c0f..41bb0bc 100644 --- a/src/classes/Unit.tscn +++ b/src/classes/Unit.tscn @@ -120,7 +120,6 @@ texture = ExtResource( 2 ) position = Vector2( 2, -12 ) hframes = 4 vframes = 6 -frame = 12 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "Idle" @@ -136,3 +135,5 @@ anims/Idle = SubResource( 5 ) [node name="UnitPopup" parent="Canvas" instance=ExtResource( 3 )] margin_right = 40.0 margin_bottom = 88.0 + +[connection signal="move_selected" from="Canvas/UnitPopup" to="." method="_on_move_selected"] diff --git a/src/nodes/UI/UnitPopup.gd b/src/nodes/UI/UnitPopup.gd index 8a08071..da94cd4 100644 --- a/src/nodes/UI/UnitPopup.gd +++ b/src/nodes/UI/UnitPopup.gd @@ -1,6 +1,8 @@ extends PopupPanel +signal move_selected(move_num) func _move_selected(move_num: int) -> void: print(move_num) hide() + emit_signal("move_selected", move_num)