From feef84ebbe4db3c44d62911a66c35221d3897dcf Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Mon, 2 Oct 2023 21:23:17 +0400 Subject: [PATCH] spell_holder --- src/models/enemies/bat/Bat.tscn | 2 +- src/models/player/Player.tscn | 1 + src/scenes/game/game.gd | 4 ++-- src/scenes/game/spell_holder.gd | 11 +++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index fed6873..24db929 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -22,7 +22,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 2 +frame = 1 playing = true centered = false diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index b21224f..65a2f32 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -124,6 +124,7 @@ visible = false position = Vector2( 11, 2 ) frames = ExtResource( 5 ) animation = "idle" +frame = 1 playing = true [node name="AudioGetDamage" type="AudioStreamPlayer" parent="."] diff --git a/src/scenes/game/game.gd b/src/scenes/game/game.gd index e7a5dbd..34f10f1 100644 --- a/src/scenes/game/game.gd +++ b/src/scenes/game/game.gd @@ -26,7 +26,7 @@ var spells = [ func _ready(): Global.playing = true - Global.play_time = 55.0 + Global.play_time = 59.0 Global.health = 5 Global.add_health(0) @@ -66,6 +66,6 @@ func _physics_process(delta): func select_card(): if selected_card != null: - $"../Center/SpellHolder".add_modifier(spells[selected_modifier]) + $"UIWrapper/UI/Center/SpellHolder".add_modifier(spells[selected_modifier], selected_modifier) Global.playing = true $UIWrapper/UI/Cards.visible = false diff --git a/src/scenes/game/spell_holder.gd b/src/scenes/game/spell_holder.gd index fab916d..6491336 100644 --- a/src/scenes/game/spell_holder.gd +++ b/src/scenes/game/spell_holder.gd @@ -1,6 +1,7 @@ extends Control var cell_preload = preload("res://src/models/spell_cell/SpellCell.tscn") +var icon_preload = preload("res://src/spell_icons/SpellIcon.tscn") var modifiers = [] func _ready(): @@ -9,5 +10,11 @@ func _ready(): spell_cell.rect_position.x += i * (14 + 2) self.add_child(spell_cell) -func add_modifier(spell_name): - modifiers.append(spell_name) +func add_modifier(spell_name, selected_modifier): + modifiers.append(spell_name) + var spell_icon = icon_preload.instance() + spell_icon.frame = selected_modifier + spell_icon.global_position.x += 7 + (modifiers.size() - 1) * (14 + 2) + spell_icon.global_position.y += 7 + self.add_child(spell_icon) +