diff --git a/scenes/PerkCard.tscn b/scenes/PerkCard.tscn new file mode 100644 index 0000000..502a9a5 --- /dev/null +++ b/scenes/PerkCard.tscn @@ -0,0 +1,101 @@ +[gd_scene format=3 uid="uid://bbhpa50ef6702"] + +[ext_resource type="Script" uid="uid://dw5y2tp34fxys" path="res://scripts/perk_card.gd" id="1_t8gqh"] +[ext_resource type="Texture2D" uid="uid://duo145bmwho8d" path="res://assets/UI assets pack 2/UI books & more.png" id="2_nlhlf"] +[ext_resource type="FontFile" uid="uid://cq0jx2aapggkg" path="res://assets/fonts/slkscrb.ttf" id="3_n4umd"] +[ext_resource type="FontFile" uid="uid://brooj0hba7650" path="res://assets/fonts/slkscr.ttf" id="4_40ty6"] +[ext_resource type="Texture2D" uid="uid://cdktimg5axaxj" path="res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_01.png" id="4_nlhlf"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_fgk3h"] +atlas = ExtResource("2_nlhlf") +region = Rect2(561, 17, 46, 62) + +[sub_resource type="LabelSettings" id="LabelSettings_qag4p"] +line_spacing = 5.0 +font = ExtResource("3_n4umd") +font_size = 12 + +[sub_resource type="AtlasTexture" id="AtlasTexture_n4umd"] +atlas = ExtResource("4_nlhlf") +region = Rect2(258, 241, 25, 14) + +[sub_resource type="LabelSettings" id="LabelSettings_ni87r"] +font = ExtResource("4_40ty6") +font_size = 11 + +[node name="PerkCard" type="Control" unique_id=1471811151] +custom_minimum_size = Vector2(200, 300) +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_t8gqh") + +[node name="Card" type="TextureRect" parent="." unique_id=1832247473] +texture_filter = 1 +custom_minimum_size = Vector2(200, 300) +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +texture = SubResource("AtlasTexture_fgk3h") + +[node name="Name" type="Label" parent="Card" unique_id=2006873472] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -50.5 +offset_top = 43.0 +offset_right = 50.5 +offset_bottom = 92.0 +grow_horizontal = 2 +text = "Zweizeilige +Überschrift +" +label_settings = SubResource("LabelSettings_qag4p") +horizontal_alignment = 1 + +[node name="TextureRect" type="TextureRect" parent="Card/Name" unique_id=2128840891] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -24.5 +offset_top = -10.0 +offset_right = 24.5 +offset_bottom = 19.0 +grow_horizontal = 2 +grow_vertical = 0 +texture = SubResource("AtlasTexture_n4umd") + +[node name="Description" type="Label" parent="Card" unique_id=859816848] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -65.0 +offset_top = -176.0 +offset_right = 69.0 +offset_bottom = -43.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Zwei +Text in Zeile Drei +Text in Zeile Vier +Text in Zeile Fünf" +label_settings = SubResource("LabelSettings_ni87r") +horizontal_alignment = 1 +autowrap_mode = 2 + +[node name="Button" type="Button" parent="." unique_id=1274377333] +layout_mode = 0 +offset_right = 200.0 +offset_bottom = 300.0 + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/scenes/game.tscn b/scenes/game.tscn index 604f5c1..d331056 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -17,6 +17,20 @@ [ext_resource type="Script" uid="uid://duauc778wc3hd" path="res://scripts/pause_menu.gd" id="18_264po"] [ext_resource type="FontFile" uid="uid://8v71dcws4q6o" path="res://assets/fonts/slkscre.ttf" id="19_1kice"] [ext_resource type="Script" uid="uid://586y330mhx8" path="res://scripts/options_menu_ingame.gd" id="20_1kice"] +[ext_resource type="Texture2D" uid="uid://dp8o40ssuh8ip" path="res://assets/Tiny RPG Mana Soul GUI v1.0/20250421barB-Sheet.png" id="16_ssvqc"] + +[sub_resource type="Resource" id="Resource_ssvqc"] +script = ExtResource("6_ir15t") +weight = 1.0 +enemy = ExtResource("7_ca42v") +metadata/_custom_type_script = "uid://b4jrogrq54c8f" + +[sub_resource type="Resource" id="Resource_264po"] +script = ExtResource("6_ir15t") +min_time = 10.0 +weight = 0.5 +enemy = ExtResource("8_rysoc") +metadata/_custom_type_script = "uid://b4jrogrq54c8f" [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vtaks"] texture = ExtResource("7_gee14") @@ -2388,24 +2402,70 @@ script = ExtResource("10_vtaks") [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1323249211] [node name="ProgressBar" type="ProgressBar" parent="CanvasLayer" unique_id=825658619] -offset_right = 607.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -303.5 +offset_right = 303.5 offset_bottom = 27.0 +grow_horizontal = 2 max_value = 5.0 step = 1.0 show_percentage = false +[node name="NinePatchRect" type="NinePatchRect" parent="CanvasLayer/ProgressBar" unique_id=1364517669] +texture_filter = 1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -6.5 +offset_top = -1.0 +offset_right = 5.5 +offset_bottom = 2.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("16_ssvqc") +draw_center = false +region_rect = Rect2(0, 0, 95, 15) +patch_margin_left = 7 +patch_margin_top = 5 +patch_margin_right = 8 +patch_margin_bottom = 6 + [node name="LevelUpManager" type="Control" parent="CanvasLayer" unique_id=292400493] process_mode = 3 layout_mode = 3 -anchors_preset = 0 -offset_right = 40.0 -offset_bottom = 40.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +grow_horizontal = 2 script = ExtResource("16_rysoc") +[node name="ColorRect" type="ColorRect" parent="CanvasLayer/LevelUpManager" unique_id=1319513730] +layout_mode = 1 +offset_left = -656.0 +offset_top = -9.0 +offset_right = 642.0 +offset_bottom = 728.0 +color = Color(0, 0, 0, 0.0627451) + [node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 +custom_minimum_size = Vector2(1000, 400) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = 350.0 +offset_right = 20.0 +offset_bottom = 390.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 50 +alignment = 1 [node name="PerkEffects" type="Node2D" parent="." unique_id=2027136639] script = ExtResource("16_ca42v") diff --git a/scripts/Perk.gd b/scripts/Perk.gd index c32ff4a..d656bb3 100644 --- a/scripts/Perk.gd +++ b/scripts/Perk.gd @@ -3,4 +3,5 @@ class_name Perk @export var name: String @export var description: String +@export var icon: Texture2D = null var effect: Callable diff --git a/scripts/explosion.gd b/scripts/explosion.gd index 7dc348c..f05a1c3 100644 --- a/scripts/explosion.gd +++ b/scripts/explosion.gd @@ -3,6 +3,7 @@ extends Area2D # Called when the node enters the scene tree for the first time. func _ready(): + await get_tree().physics_frame for body in get_overlapping_bodies(): if body.is_in_group("enemies"): body.hit() diff --git a/scripts/fireball.gd b/scripts/fireball.gd index 526921a..42421c0 100644 --- a/scripts/fireball.gd +++ b/scripts/fireball.gd @@ -10,6 +10,6 @@ func _on_body_entered(body: Node2D) -> void: if fireball_aoe: var boom = explosion_scene.instantiate() boom.global_position = global_position - get_parent().add_child(boom) + get_parent().call_deferred("add_child", boom) queue_free() diff --git a/scripts/level_up_manager.gd b/scripts/level_up_manager.gd index df3766e..a04db52 100644 --- a/scripts/level_up_manager.gd +++ b/scripts/level_up_manager.gd @@ -2,7 +2,9 @@ extends Control @onready var perk_effects = get_node("/root/Game/PerkEffects") + var perks +@onready var perkCard = preload("res://scenes/PerkCard.tscn") # Called when the node enters the scene tree for the first time. func _ready() -> void: perks = perk_effects.available_perks @@ -17,18 +19,23 @@ func _process(delta: float) -> void: func show_perks(): if perks.is_empty(): return + var tween = create_tween() + tween.tween_property($ColorRect, "color:a", 0.6, 0.3) get_tree().paused = true var shuffled = perks.duplicate() shuffled.shuffle() var chosen = shuffled.slice(0, 3) for x in chosen: - var button = Button.new() - button.text = x.name + "\n" + x.description - button.pressed.connect(func(): select_perk(x)) - $HBoxContainer.add_child(button) + var card = perkCard.instantiate() + $HBoxContainer.add_child(card) + card.setup(x, func(): select_perk(x)) + func select_perk(perk): perk.effect.call() get_tree().paused = false perks.erase(perk) for child in $HBoxContainer.get_children(): child.queue_free() + var tween = create_tween() + tween.tween_property($ColorRect, "color:a", 0.0, 0.3) + await tween.finished diff --git a/scripts/perk_card.gd b/scripts/perk_card.gd new file mode 100644 index 0000000..cb622da --- /dev/null +++ b/scripts/perk_card.gd @@ -0,0 +1,42 @@ +extends Control +@export var icon: Texture2D +# Called when the node enters the scene tree for the first time. +var on_select: Callable + + + +func setup(perk: Perk, select: Callable): + $Button.modulate.a = 0 + $Card/Name.text = perk.name + $Card/Description.text = perk.description + if perk.icon != null: + $Card/Name/TextureRect.texture = perk.icon + animate_in() + $Button.modulate.a = 0.3 + $Button.mouse_entered.connect(func(): $Button.modulate.a = 0.6) + $Button.mouse_exited.connect(func(): $Button.modulate.a = 0.3) + on_select = select + + + +func _on_button_pressed() -> void: + await animate_out() + on_select.call() + pass # Replace with function body. + +func animate_in(): + await get_tree().process_frame + var start_y = global_position.y + 500 + var end_y = global_position.y + global_position.y = start_y + var tween = create_tween() + tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD) + +func animate_out(): + var start_y = global_position.y + var end_y = global_position.y - 500 + global_position.y = start_y + var tween = create_tween() + tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD) + await tween.finished + diff --git a/scripts/perk_card.gd.uid b/scripts/perk_card.gd.uid new file mode 100644 index 0000000..b0c3dcd --- /dev/null +++ b/scripts/perk_card.gd.uid @@ -0,0 +1 @@ +uid://dw5y2tp34fxys diff --git a/scripts/perk_effects.gd b/scripts/perk_effects.gd index e8d0a4e..3306a28 100644 --- a/scripts/perk_effects.gd +++ b/scripts/perk_effects.gd @@ -12,17 +12,17 @@ func _ready() -> void: cauldron = witch.get_node("CauldronBar") var dsh = Perk.new() dsh.name = "Doppelter Shuriken" - dsh.description = "Wirft zwei Shurikens statt einem" + dsh.description = "Wirft zwei Shurikens\n statt einem" dsh.effect = double_shuriken available_perks.append(dsh) var faoe = Perk.new() faoe.name = "AOE-Fireball" - faoe.description = "Feuerbälle erzeugen eine Explosion bei Berührung" + faoe.description = "Feuerbälle erzeugen\n eine Explosion\n bei Berührung" faoe.effect = fireball_aoe available_perks.append(faoe) var bexp = Perk.new() bexp.name = "Brewing-Explosion" - bexp.description = "Die Hexe erzeugt eine Explosion am Ende des Brauens" + bexp.description = "Die Hexe erzeugt\n eine Explosion am\n Ende des Brauens" bexp.effect = brew_explosion available_perks.append(bexp)