game: add levelups

This commit is contained in:
2025-08-20 01:59:45 +02:00
parent eec0e6a50f
commit c3f49c885a
13 changed files with 265 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
class_name LevelUpChoice
extends PanelContainer
@export var player: Player
@export var mod: PlayerStatsModifier
signal lvlup_picked(mod: PlayerStatsModifier)
@onready var upgrade_name: Label = $MarginContainer/VBoxContainer/UpgradeName
@onready var upgrade_description: Label = $MarginContainer/VBoxContainer/UpgradeDescription
@onready var upgrade_tex: TextureRect = $MarginContainer/VBoxContainer/CenterContainer/UpgradeTex
func _ready() -> void:
match mod.rarity:
GlobalConst.ModRarity.NORMAL:
upgrade_name.add_theme_color_override("font_color", Color.WHITE)
GlobalConst.ModRarity.RARE:
upgrade_name.add_theme_color_override("font_color", Color.DODGER_BLUE)
GlobalConst.ModRarity.EPIC:
upgrade_name.add_theme_color_override("font_color", Color.DARK_ORCHID)
GlobalConst.ModRarity.LEGENDARY:
upgrade_name.add_theme_color_override("font_color", Color.DARK_ORANGE)
upgrade_name.text = mod.title
upgrade_description.text = mod.description
upgrade_tex.texture = mod.tex
func _on_pick_button_pressed() -> void:
player.modifiers.append(mod)
print_debug("player mods: %s" % len(player.modifiers))
Engine.time_scale = 1.0
lvlup_picked.emit(mod)
queue_free()

View File

@@ -0,0 +1 @@
uid://c5wglrsnl38v2

View File

@@ -0,0 +1,46 @@
[gd_scene load_steps=3 format=3 uid="uid://cbjae7oyakpfw"]
[ext_resource type="Script" uid="uid://c5wglrsnl38v2" path="res://scenes/managers/ui/level_up_choice.gd" id="1_afnb8"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_a1rnr"]
size = Vector2(64, 64)
[node name="LevelUpChoice" type="PanelContainer"]
offset_right = 220.0
offset_bottom = 270.0
script = ExtResource("1_afnb8")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 20
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="UpgradeName" type="Label" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "+10% Area of attack"
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="UpgradeTex" type="TextureRect" parent="MarginContainer/VBoxContainer/CenterContainer"]
layout_mode = 2
texture = SubResource("PlaceholderTexture2D_a1rnr")
stretch_mode = 4
[node name="UpgradeDescription" type="Label" parent="MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(200, 100)
layout_mode = 2
theme_override_font_sizes/font_size = 8
text = "Bla bla, this gives you 10% bigger attacks lol"
autowrap_mode = 2
[node name="PickButton" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Pick"
[connection signal="pressed" from="MarginContainer/VBoxContainer/PickButton" to="." method="_on_pick_button_pressed"]

View File

@@ -0,0 +1,15 @@
class_name LevelUpUI
extends Control
@onready var choice_container: HBoxContainer = $VBoxContainer/PanelContainer/CenterContainer/ChoiceContainer
func clear():
for child in choice_container.get_children():
child.queue_free()
func add_choice(choice: LevelUpChoice) -> void:
choice.lvlup_picked.connect(_on_levelup_picked)
choice_container.add_child(choice)
func _on_levelup_picked(mod: PlayerStatsModifier) -> void:
visible = false

View File

@@ -0,0 +1 @@
uid://dybfo3bablxhk

View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=2 format=3 uid="uid://isg7vt4l7eem"]
[ext_resource type="Script" uid="uid://dybfo3bablxhk" path="res://scenes/managers/ui/level_up_ui.gd" id="1_5751k"]
[node name="LevelUpUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_5751k")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -334.0
offset_top = -135.0
offset_right = 334.0
offset_bottom = 135.0
grow_horizontal = 2
grow_vertical = 2
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer/PanelContainer"]
layout_mode = 2
[node name="ChoiceContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer/CenterContainer"]
layout_mode = 2

View File

@@ -4,8 +4,10 @@ extends Control
@onready var pause_ui: PauseUI = $CanvasLayer/PauseUI
@onready var player_ui: PlayerUI = $CanvasLayer/PlayerUI
@onready var debug_ui: DebugUI = $CanvasLayer/DebugUI
@onready var level_up_ui: LevelUpUI = $CanvasLayer/LevelUpUI
func _ready() -> void:
pause_ui.visible = false
player_ui.visible = true
level_up_ui.visible = false

View File

@@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://b18uib08hvdpq"]
[gd_scene load_steps=6 format=3 uid="uid://b18uib08hvdpq"]
[ext_resource type="Script" uid="uid://dcxc70fvu7kl2" path="res://scenes/managers/ui/main_ui.gd" id="1_3a826"]
[ext_resource type="Script" uid="uid://sjnxf0hj3egp" path="res://scenes/managers/ui/pause_ui.gd" id="1_lke1m"]
[ext_resource type="Script" uid="uid://dbq74tvxtpfjc" path="res://scenes/managers/ui/player_ui.gd" id="3_gaipe"]
[ext_resource type="Script" uid="uid://d2o6tqnqg2o25" path="res://scenes/managers/ui/debug_ui.gd" id="4_217l8"]
[ext_resource type="PackedScene" uid="uid://isg7vt4l7eem" path="res://scenes/managers/ui/level_up_ui.tscn" id="5_cfhdr"]
[node name="MainUI" type="Control"]
layout_mode = 3
@@ -161,6 +162,8 @@ mouse_filter = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/DebugUI/StatsContainer"]
layout_mode = 2
[node name="LevelUpUI" parent="CanvasLayer" instance=ExtResource("5_cfhdr")]
[connection signal="pressed" from="CanvasLayer/PauseUI/CenterContainer/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/ResumeButton" to="CanvasLayer/PauseUI" method="_on_resume_button_pressed"]
[connection signal="pressed" from="CanvasLayer/PauseUI/CenterContainer/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/NewGameBtuton" to="CanvasLayer/PauseUI" method="_on_new_game_btuton_pressed"]
[connection signal="pressed" from="CanvasLayer/PauseUI/CenterContainer/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/OptionsButton" to="CanvasLayer/PauseUI" method="_on_options_button_pressed"]