Nivel de prueba reimplementado

This commit is contained in:
Diego De la Viuda Llorente committed 2026-10-21 10:56:11 +02:00
1 parent 8fc8925151
commit 1e70a99224
24 files changed
+2384 -164

No files matched your search

+29 -20
View File
@@ -10,36 +10,45 @@ extends CanvasLayer
@onready var health_bar: ProgressBar = $HUD/HealthBar
@onready var health_label: Label = $HUD/HealthBar/HealthLabel
@onready var speed_label: Label = $HUD/SpeedLabel
@onready var effects_label: Label = $HUD/EffectsLabel
var player_ref: Node
func _ready() -> void:
var player: Node = get_parent()
player_ref = player
if player == null or not player.has_signal(&"health_changed"):
push_error("PlayerHealthHUD must be a child of a Player with health_changed signal.")
player_ref = get_parent()
if not player_ref.has_signal(&"health_changed"):
push_error("PlayerHealthHUD must be a child of a Player.")
return
# Child _ready() runs before Player._ready(). We connect here first and the
# Player will emit its initial health value a moment later during its _ready().
player.connect(&"health_changed", _on_health_changed)
if speed_label:
speed_label.visible = false
# Children enter _ready before Player. Its initial signal arrives afterward.
player_ref.connect(&"health_changed", _on_health_changed)
effects_label.visible = false
func _process(_delta: float) -> void:
if player_ref == null or speed_label == null:
if player_ref == null:
return
if "get" in player_ref and player_ref.has_method("get"):
pass
var t = player_ref.get("_speed_boost_timer")
if t != null and float(t) > 0.0:
speed_label.visible = true
speed_label.text = "SPEED UP: %ds" % int(float(t))
else:
speed_label.visible = false
# Display each active effect individually: essential when validating all
# eight pickup families on a phone. Property names match Player's timers.
var active: Array[String] = []
for effect in [
["VELOCIDAD", "_speed_boost_timer"],
["DANO", "_damage_boost_timer"],
["GOLPE AEREO", "_air_damage_boost_timer"],
["DEFENSA", "_damage_reduction_timer"],
["SALTO", "_jump_boost_timer"],
]:
var seconds: float = float(player_ref.get(effect[1]))
if seconds > 0.0:
active.append("%s: %ds" % [effect[0], ceili(seconds)])
var shield_hits: int = int(player_ref.get("_shield_hits"))
if shield_hits > 0:
active.append("ESCUDO: %d golpe(s)" % shield_hits)
effects_label.visible = not active.is_empty()
effects_label.text = "\n".join(active)
func _on_health_changed(current_health: int, max_health: int) -> void:
+7 -7
View File
@@ -64,16 +64,16 @@ text = "HP 5 / 5"
horizontal_alignment = 1
vertical_alignment = 1
[node name="SpeedLabel" type="Label" parent="HUD"]
[node name="EffectsLabel" type="Label" parent="HUD"]
layout_mode = 0
offset_left = 18.0
offset_top = 70.0
offset_right = 278.0
offset_bottom = 98.0
offset_top = 106.0
offset_right = 298.0
offset_bottom = 255.0
theme_override_colors/font_color = Color(1, 0.8, 0.2, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
theme_override_font_sizes/font_size = 16
text = "SPEED UP: 0s"
horizontal_alignment = 1
vertical_alignment = 1
text = "VELOCIDAD: 0s"
horizontal_alignment = 0
vertical_alignment = 0
visible = false
+3 -3
View File
@@ -15,9 +15,9 @@ mouse_filter = 2
[node name="SpecialBar" type="ProgressBar" parent="HUD"]
offset_left = 18.0
offset_top = 44.0
offset_right = 220.0
offset_bottom = 64.0
offset_top = 74.0
offset_right = 278.0
offset_bottom = 94.0
max_value = 100.0
value = 0.0
show_percentage = false