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: