Mejoras en la creacion de niveles, y el hud del jugador

This commit is contained in:
Diego De la Viuda Llorente committed 2026-10-29 15:25:31 +01:00
1 parent fd0118d964
commit 5b1a434778
29 files changed
+3210 -101

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
@tool
extends Node
## Se coloca como hijo directo de un CanvasLayer de interfaz.
## Oculta esa capa al editar escenarios o personajes, pero la muestra al abrir
## su propia escena. No ejecuta la logica de vida, combate ni controles en el editor.
## Al jugar restaura la capa una vez y deja de procesar; las reglas del juego
## pueden seguir ocultando la interfaz o sus paneles cuando lo necesiten.
## Permite ver esta interfaz tambien dentro de un nivel mientras se edita.
## No afecta a la partida. Normalmente conviene editar la escena de UI por separado.
@export var preview_in_editor: bool = false:
set(value):
preview_in_editor = value
if Engine.is_editor_hint():
_update_visibility()
## _enter_tree tambien se ejecuta al volver a una pestana del editor.
func _enter_tree() -> void:
_update_visibility()
## Godot habilita _process antes de _ready si existe ese callback.
## Se desactiva aqui, no en _enter_tree, para no interferir durante la partida.
func _ready() -> void:
set_process(Engine.is_editor_hint())
## Solo se procesa en el editor: la raiz editada puede establecerse despues
## de _enter_tree o cambiar al abrir otra pestana. No recorre el arbol de nodos.
func _process(_delta: float) -> void:
if Engine.is_editor_hint():
_update_visibility()
## Al arrancar el juego muestra la capa aunque se guardase oculta en el editor.
## No cambia la visibilidad individual de sus hijos (efectos, mensajes, etc.).
func _update_visibility() -> void:
if not is_inside_tree():
return
var canvas_layer := get_parent() as CanvasLayer
if canvas_layer == null:
return
var should_be_visible: bool = true
if Engine.is_editor_hint():
should_be_visible = preview_in_editor or get_tree().edited_scene_root == canvas_layer
if canvas_layer.visible != should_be_visible:
canvas_layer.visible = should_be_visible
func _get_configuration_warnings() -> PackedStringArray:
if not get_parent() is CanvasLayer:
return PackedStringArray(["EditorVisibility debe ser hijo directo de un CanvasLayer de interfaz."])
return PackedStringArray()
+34 -10
View File
@@ -1,31 +1,49 @@
extends CanvasLayer
## Interfaz de vida en CanvasLayer: sus coordenadas pertenecen a la ventana,
## no al escenario. Se mantiene en la misma esquina aunque avance la camara.
## Conecta el estado de Player con el HUD. La estetica y la animacion viven en ThrashMeter.
## CanvasLayer mantiene la interfaz fija en pantalla aunque avance la camara.
@onready var health_bar: ProgressBar = $HUD/HealthBar
## Umbral de aviso visual; no cambia la vida ni la dificultad del combate.
@export_range(0.05, 0.5, 0.05) var low_health_ratio: float = 0.25
@onready var health_bar: ThrashMeter = $HUD/HealthBar
@onready var health_label: Label = $HUD/HealthBar/HealthLabel
@onready var effects_label: Label = $HUD/EffectsLabel
@onready var warning_label: Label = $HUD/WarningLabel
var player_ref: Node
var _received_health: bool = false
var _effects_refresh_timer: float = 0.0
## Valida el contrato del jugador y conecta la senal de vida.
func _ready() -> void:
player_ref = get_parent()
if not player_ref.has_signal(&"health_changed"):
push_error("PlayerHealthHUD must be a child of a Player.")
if player_ref == null or not player_ref.has_signal(&"health_changed"):
# Abrir esta escena sola permite revisar su diseno sin crear un jugador de mentira.
player_ref = null
set_process(false)
return
# Los hijos ejecutan _ready antes que Player; su senal inicial llegara despues de esta conexion.
player_ref.connect(&"health_changed", _on_health_changed)
effects_label.visible = false
# Tambien funciona si el HUD se instancia despues de _ready del jugador.
if player_ref.is_node_ready():
var data: Resource = player_ref.get("character_data") as Resource
if data != null:
_on_health_changed(int(player_ref.get("current_health")), int(data.get("max_health")))
## Actualiza los tiempos restantes de las mejoras temporales.
func _process(_delta: float) -> void:
if player_ref == null:
func _process(delta: float) -> void:
if not is_instance_valid(player_ref):
return
# Los contadores muestran segundos: refrescarlos a 10 Hz evita reconstruir texto cada frame.
_effects_refresh_timer -= delta
if _effects_refresh_timer > 0.0:
return
_effects_refresh_timer = 0.1
# Muestra cada mejora por separado. Los nombres de propiedades corresponden al estado temporal de Player.
var active: Array[String] = []
@@ -55,6 +73,12 @@ func _process(_delta: float) -> void:
## Sincroniza barra y texto a partir del mismo par de valores.
func _on_health_changed(current_health: int, max_health: int) -> void:
health_bar.max_value = float(max_health)
health_bar.value = float(current_health)
health_label.text = "HP %d / %d" % [current_health, max_health]
var capacity: int = maxi(max_health, 0)
var amount: int = clampi(current_health, 0, capacity)
health_bar.set_amount(amount, capacity, not _received_health)
_received_health = true
health_label.text = "%d / %d" % [amount, capacity]
var low_health: bool = capacity > 0 and float(amount) / float(capacity) <= low_health_ratio
health_bar.highlighted = low_health and amount > 0
warning_label.visible = low_health or amount == 0
warning_label.text = "SIN VIDA" if amount == 0 else "PELIGRO"
+79 -50
View File
@@ -1,30 +1,19 @@
[gd_scene load_steps=4 format=3]
[gd_scene load_steps=7 format=3]
[ext_resource type="Script" path="res://ui/hud/player_health_hud.gd" id="1_hud"]
[sub_resource type="StyleBoxFlat" id="HealthBackground"]
bg_color = Color(0.08, 0.08, 0.09, 0.82)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.95, 0.95, 0.95, 0.75)
corner_radius_top_left = 7
corner_radius_top_right = 7
corner_radius_bottom_right = 7
corner_radius_bottom_left = 7
[sub_resource type="StyleBoxFlat" id="HealthFill"]
bg_color = Color(0.72, 0.06, 0.06, 0.92)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[ext_resource type="Script" path="res://ui/editor_ui_visibility.gd" id="editor_ui_visibility"]
[ext_resource type="Script" path="res://ui/hud/thrash_meter.gd" id="meter"]
[ext_resource type="Theme" path="res://ui/hud/thrash_hud_theme.tres" id="theme"]
[ext_resource type="Texture2D" path="res://assets/ui/hud/thrash_plate.svg" id="plate"]
[ext_resource type="Texture2D" path="res://assets/ui/hud/thrash_skull.svg" id="skull"]
[node name="PlayerHealthHUD" type="CanvasLayer"]
layer = 90
script = ExtResource("1_hud")
[node name="EditorVisibility" type="Node" parent="."]
script = ExtResource("editor_ui_visibility")
[node name="HUD" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
@@ -33,47 +22,87 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme = ExtResource("theme")
[node name="HealthBar" type="ProgressBar" parent="HUD"]
[node name="Frame" type="TextureRect" parent="HUD"]
layout_mode = 0
offset_left = 18.0
offset_top = 18.0
offset_right = 278.0
offset_bottom = 58.0
offset_right = 362.0
offset_bottom = 82.0
mouse_filter = 2
theme_override_styles/background = SubResource("HealthBackground")
theme_override_styles/fill = SubResource("HealthFill")
max_value = 5.0
value = 5.0
show_percentage = false
texture = ExtResource("plate")
expand_mode = 1
[node name="HealthLabel" type="Label" parent="HUD/HealthBar"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Emblem" type="TextureRect" parent="HUD"]
layout_mode = 0
offset_left = 29.0
offset_top = 26.0
offset_right = 69.0
offset_bottom = 66.0
mouse_filter = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
theme_override_constants/shadow_offset_x = 1
theme_override_constants/shadow_offset_y = 1
theme_override_font_sizes/font_size = 18
text = "HP 5 / 5"
texture = ExtResource("skull")
expand_mode = 1
[node name="Title" type="Label" parent="HUD"]
layout_mode = 0
offset_left = 84.0
offset_top = 25.0
offset_right = 152.0
offset_bottom = 45.0
mouse_filter = 2
text = "VIDA"
vertical_alignment = 1
[node name="WarningLabel" type="Label" parent="HUD"]
visible = false
layout_mode = 0
offset_left = 154.0
offset_top = 25.0
offset_right = 212.0
offset_bottom = 45.0
mouse_filter = 2
theme_override_colors/font_color = Color(1, 0.52, 0.42, 1)
theme_override_font_sizes/font_size = 8
text = "PELIGRO"
horizontal_alignment = 1
vertical_alignment = 1
[node name="EffectsLabel" type="Label" parent="HUD"]
[node name="HealthBar" type="ProgressBar" parent="HUD"]
layout_mode = 0
offset_left = 18.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)
offset_left = 84.0
offset_top = 48.0
offset_right = 346.0
offset_bottom = 68.0
mouse_filter = 2
max_value = 50.0
value = 50.0
show_percentage = false
script = ExtResource("meter")
fill_color = Color(0.84, 0.18, 0.25, 1)
segment_count = 12
[node name="HealthLabel" type="Label" parent="HUD/HealthBar"]
layout_mode = 0
offset_left = 132.0
offset_top = -23.0
offset_right = 262.0
offset_bottom = -3.0
mouse_filter = 2
text = "50 / 50"
horizontal_alignment = 2
vertical_alignment = 1
[node name="EffectsLabel" type="Label" parent="HUD"]
visible = false
layout_mode = 0
offset_left = 22.0
offset_top = 160.0
offset_right = 362.0
offset_bottom = 300.0
mouse_filter = 2
theme_override_colors/font_color = Color(0.85, 0.9, 0.64, 1)
theme_override_font_sizes/font_size = 16
text = "VELOCIDAD: 0s"
text = ""
horizontal_alignment = 0
vertical_alignment = 0
visible = false
+40 -16
View File
@@ -1,27 +1,51 @@
extends CanvasLayer
## Presenta la carga y su umbral real de uso; no altera costes ni ejecuta ataques.
## Los valores proceden del jugador, no de otra configuracion duplicada en el HUD.
## Medidor de carga especial. Debe ser hijo de un jugador que emita
## special_charge_changed, igual que el HUD de vida depende de health_changed.
@onready var special_bar: ProgressBar = $HUD/SpecialBar
@onready var special_bar: ThrashMeter = $HUD/SpecialBar
@onready var special_label: Label = $HUD/SpecialBar/SpecialLabel
@onready var status_label: Label = $HUD/StatusLabel
@onready var threshold_label: Label = $HUD/ThresholdLabel
var player_ref: Node
var _received_charge: bool = false
## Conecta el medidor antes de recibir el estado inicial del jugador.
func _ready() -> void:
var player: Node = get_parent()
if player == null or not player.has_signal(&"special_charge_changed"):
push_error("SpecialChargeHUD must be a child of a Player with special_charge_changed signal.")
player_ref = get_parent()
if player_ref == null or not player_ref.has_signal(&"special_charge_changed"):
# Conserva la maqueta al ejecutar solo esta escena de interfaz.
player_ref = null
return
# Se conecta antes del _ready del jugador para recibir tambien la carga inicial.
player.connect(&"special_charge_changed", _on_special_charge_changed)
player_ref.connect(&"special_charge_changed", _on_special_charge_changed)
if player_ref.is_node_ready():
_on_special_charge_changed(int(player_ref.get("special_charge")), int(player_ref.get("special_max_charge")))
## Actualiza la barra y la etiqueta de carga especial.
## El porcentaje se calcula respecto a la capacidad: 25 de 50 es 50%, no 25%.
## LISTO indica carga suficiente; los bloqueos temporales de combate siguen siendo de Player.
func _on_special_charge_changed(current_charge: int, max_charge: int) -> void:
special_bar.max_value = float(max_charge)
special_bar.value = float(current_charge)
special_label.text = "SPECIAL %d%%" % [current_charge]
var capacity: int = maxi(max_charge, 0)
var amount: int = clampi(current_charge, 0, capacity)
var minimum: int = maxi(int(player_ref.get("special_min_use_charge")), 1)
var available: bool = capacity > 0 and minimum <= capacity
var charged: bool = available and amount >= minimum
var percent: int = roundi(100.0 * float(amount) / float(maxi(capacity, 1)))
special_bar.set_amount(amount, capacity, not _received_charge)
_received_charge = true
special_bar.activation_ratio = float(minimum) / float(capacity) if available else -1.0
special_bar.highlighted = charged
special_label.text = "%d%%" % percent
# La leyenda usa puntos, porque la capacidad es configurable y no siempre vale 100.
threshold_label.text = "MIN %d PT" % minimum if available else "NO DISPONIBLE"
if not available:
status_label.text = "DESACTIVADO"
elif amount == capacity:
status_label.text = "AL 11"
elif charged:
status_label.text = "LISTO"
else:
status_label.text = "CARGANDO"
status_label.add_theme_color_override("font_color", Color("e4f39a") if charged else Color("93a3a0"))
+85 -16
View File
@@ -1,37 +1,106 @@
[gd_scene load_steps=2 format=3]
[gd_scene load_steps=7 format=3]
[ext_resource type="Script" path="res://ui/hud/special_charge_hud.gd" id="1_hud"]
[ext_resource type="Script" path="res://ui/editor_ui_visibility.gd" id="editor_ui_visibility"]
[ext_resource type="Script" path="res://ui/hud/thrash_meter.gd" id="meter"]
[ext_resource type="Theme" path="res://ui/hud/thrash_hud_theme.tres" id="theme"]
[ext_resource type="Texture2D" path="res://assets/ui/hud/thrash_plate.svg" id="plate"]
[ext_resource type="Texture2D" path="res://assets/ui/hud/thrash_bolt.svg" id="bolt"]
[node name="SpecialChargeHUD" type="CanvasLayer"]
layer = 95
script = ExtResource("1_hud")
[node name="EditorVisibility" type="Node" parent="."]
script = ExtResource("editor_ui_visibility")
[node name="HUD" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme = ExtResource("theme")
[node name="Frame" type="TextureRect" parent="HUD"]
layout_mode = 0
offset_left = 18.0
offset_top = 86.0
offset_right = 362.0
offset_bottom = 150.0
mouse_filter = 2
texture = ExtResource("plate")
expand_mode = 1
[node name="Emblem" type="TextureRect" parent="HUD"]
layout_mode = 0
offset_left = 29.0
offset_top = 94.0
offset_right = 69.0
offset_bottom = 134.0
mouse_filter = 2
texture = ExtResource("bolt")
expand_mode = 1
[node name="Title" type="Label" parent="HUD"]
layout_mode = 0
offset_left = 84.0
offset_top = 93.0
offset_right = 155.0
offset_bottom = 113.0
mouse_filter = 2
text = "SOLO"
vertical_alignment = 1
[node name="StatusLabel" type="Label" parent="HUD"]
layout_mode = 0
offset_left = 158.0
offset_top = 93.0
offset_right = 270.0
offset_bottom = 113.0
mouse_filter = 2
theme_override_colors/font_color = Color(0.57, 0.64, 0.63, 1)
theme_override_font_sizes/font_size = 8
text = "CARGANDO"
horizontal_alignment = 1
vertical_alignment = 1
[node name="SpecialBar" type="ProgressBar" parent="HUD"]
offset_left = 18.0
offset_top = 74.0
offset_right = 278.0
offset_bottom = 94.0
layout_mode = 0
offset_left = 84.0
offset_top = 116.0
offset_right = 346.0
offset_bottom = 134.0
mouse_filter = 2
max_value = 100.0
value = 0.0
show_percentage = false
script = ExtResource("meter")
fill_color = Color(0.74, 0.89, 0.27, 1)
segment_count = 16
activation_ratio = 0.25
show_damage_trail = false
[node name="SpecialLabel" type="Label" parent="HUD/SpecialBar"]
layout_mode = 1
anchors_preset = 15
offset_left = 4.0
offset_top = 2.0
text = "SPECIAL"
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
theme_override_constants/shadow_offset_x = 1
theme_override_constants/shadow_offset_y = 1
theme_override_font_sizes/font_size = 14
horizontal_alignment = 1
layout_mode = 0
offset_left = 192.0
offset_top = -23.0
offset_right = 262.0
offset_bottom = -3.0
mouse_filter = 2
text = "0%"
horizontal_alignment = 2
vertical_alignment = 1
[node name="ThresholdLabel" type="Label" parent="HUD"]
layout_mode = 0
offset_left = 84.0
offset_top = 136.0
offset_right = 244.0
offset_bottom = 146.0
mouse_filter = 2
theme_override_colors/font_color = Color(0.66, 0.71, 0.64, 1)
theme_override_font_sizes/font_size = 8
text = "MIN 25 PT"
+15
View File
@@ -0,0 +1,15 @@
[gd_resource type="Theme" load_steps=3 format=3]
[ext_resource type="FontFile" path="res://assets/fonts/PixelOperator8.ttf" id="pixel_font"]
[sub_resource type="StyleBoxEmpty" id="EmptyBar"]
[resource]
default_font = ExtResource("pixel_font")
default_font_size = 16
Label/colors/font_color = Color(0.91, 0.91, 0.82, 1)
Label/colors/font_shadow_color = Color(0.02, 0.03, 0.04, 1)
Label/constants/shadow_offset_x = 1
Label/constants/shadow_offset_y = 1
ProgressBar/styles/background = SubResource("EmptyBar")
ProgressBar/styles/fill = SubResource("EmptyBar")
+193
View File
@@ -0,0 +1,193 @@
@tool
class_name ThrashMeter
extends ProgressBar
## Medidor visual compartido por vida y especial; no conoce al jugador ni modifica el combate.
## Conserva el contrato de ProgressBar (value/max_value) y dibuja segmentos de amplificador.
## Solo este componente visual se ejecuta en el editor; los controladores del HUD no son @tool.
@export_group("Thrash Appearance")
## Color de los segmentos llenos. La escena de vida usa rojo y la de especial, verde acido.
@export var fill_color: Color = Color("d73949"):
set(new_value):
fill_color = new_value
queue_redraw()
@export_range(4, 32, 1) var segment_count: int = 12:
set(new_value):
segment_count = new_value
queue_redraw()
## Fraccion de la capacidad donde dibujar la marca de activacion. -1 la oculta.
@export_range(-1.0, 1.0, 0.01) var activation_ratio: float = -1.0:
set(new_value):
activation_ratio = new_value
queue_redraw()
@export_group("Thrash Feedback")
## Desactivar para obtener un HUD estatico: sin pulsos, destellos ni interpolacion.
@export var animations_enabled: bool = true:
set(new_value):
animations_enabled = new_value
if not new_value:
_snap_to_value()
_update_processing()
## Conserva brevemente la vida perdida en color hueso. El especial no necesita esta estela.
@export var show_damage_trail: bool = true
@export_range(0.0, 1.0, 0.05) var damage_trail_delay: float = 0.35
## Duracion de cada subida, incluso cuando solo se ganan 10 puntos.
@export_range(0.05, 1.0, 0.05) var fill_transition_seconds: float = 0.2
## El controlador decide cuando destacar la barra: poca vida o carga suficiente.
var highlighted: bool = false:
set(new_value):
highlighted = new_value
queue_redraw()
_update_processing()
var _display_ratio: float = 0.0
var _target_ratio: float = 0.0
var _fill_speed: float = 0.0
var _trail_ratio: float = 0.0
var _trail_wait: float = 0.0
var _damage_flash: float = 0.0
var _pulse_phase: float = 0.0
var _updating_range: bool = false
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_IGNORE
value_changed.connect(_on_value_changed)
changed.connect(_on_range_changed)
resized.connect(queue_redraw)
_snap_to_value()
_update_processing()
## Actualiza valor y capacidad como una sola operacion; la primera lectura no se anima.
## Una capacidad cero se representa vacia y nunca provoca una division por cero.
func set_amount(current: float, capacity: float, immediate: bool = false) -> void:
# Cambiar la escala del medidor no es recibir dano: reinicia la representacion visual.
var capacity_changed: bool = not is_equal_approx(max_value, maxf(capacity, 1.0))
_updating_range = true
max_value = maxf(capacity, 1.0)
value = clampf(current, 0.0, maxf(capacity, 0.0))
_updating_range = false
if immediate or capacity_changed or Engine.is_editor_hint() or not animations_enabled:
_snap_to_value()
else:
_change_target()
_update_processing()
func _on_value_changed(_new_value: float) -> void:
if not _updating_range:
if Engine.is_editor_hint() or not animations_enabled:
_snap_to_value()
else:
_change_target()
_update_processing()
func _on_range_changed() -> void:
# Range.changed notifica tambien los cambios de capacidad desde el Inspector.
_on_value_changed(value)
func _snap_to_value() -> void:
_target_ratio = clampf(value / maxf(max_value, 1.0), 0.0, 1.0)
_display_ratio = _target_ratio
_fill_speed = 0.0
_trail_ratio = _target_ratio
_trail_wait = 0.0
_damage_flash = 0.0
queue_redraw()
func _change_target() -> void:
var next_ratio: float = clampf(value / maxf(max_value, 1.0), 0.0, 1.0)
if next_ratio < _target_ratio:
# Perder vida o consumir el solo se muestra al instante; no se finge energia disponible.
_display_ratio = next_ratio
if show_damage_trail:
_trail_ratio = maxf(_trail_ratio, _target_ratio)
_trail_wait = damage_trail_delay
_damage_flash = 0.18
_target_ratio = next_ratio
_fill_speed = absf(_target_ratio - _display_ratio) / maxf(fill_transition_seconds, 0.05)
if not show_damage_trail:
_trail_ratio = next_ratio
queue_redraw()
func _update_processing() -> void:
# Una barra estable no redibuja cada frame. El editor solo cambia al tocar sus propiedades.
if not is_inside_tree():
return
var moving: bool = not is_equal_approx(_display_ratio, _target_ratio)
var trailing: bool = show_damage_trail and not is_equal_approx(_trail_ratio, _target_ratio)
set_process(not Engine.is_editor_hint() and animations_enabled and
(highlighted or moving or trailing or _damage_flash > 0.0))
func _process(delta: float) -> void:
_display_ratio = move_toward(_display_ratio, _target_ratio, delta * _fill_speed)
_trail_wait = maxf(0.0, _trail_wait - delta)
if _trail_wait <= 0.0:
_trail_ratio = move_toward(_trail_ratio, _target_ratio, delta / 0.45)
_damage_flash = maxf(0.0, _damage_flash - delta)
# Pulso lento y localizado; no parpadea toda la pantalla ni mueve los controles.
_pulse_phase = fmod(_pulse_phase + delta * TAU * 0.75, TAU)
if is_visible_in_tree():
queue_redraw()
_update_processing()
func _draw() -> void:
if size.x < 8.0 or size.y < 6.0:
return
var shown: float = clampf(value / maxf(max_value, 1.0), 0.0, 1.0) if Engine.is_editor_hint() else _display_ratio
var inner := Rect2(Vector2(2, 2), size - Vector2(4, 4))
var count: int = maxi(segment_count, 1)
var step_width: float = inner.size.x / float(count)
var cell_width: float = maxf(step_width - 2.0, 1.0)
draw_rect(Rect2(Vector2.ZERO, size), Color("05090b"))
draw_rect(Rect2(Vector2.ZERO, size), Color("3b464b"), false, 1.0)
for index: int in range(count):
var cell := Rect2(inner.position + Vector2(float(index) * step_width, 0), Vector2(cell_width, inner.size.y))
_draw_segment(cell, 1.0, Color("202b30"))
if show_damage_trail and not Engine.is_editor_hint():
_draw_segment(cell, clampf(_trail_ratio * count - index, 0.0, 1.0), Color("a99774"))
var fraction: float = clampf(shown * count - index, 0.0, 1.0)
_draw_segment(cell, fraction, fill_color)
if fraction > 0.0:
# Bisel iluminado y una linea de sombra dentro de cada segmento.
var bevel: float = minf(3.0, cell.size.x * 0.25)
var length: float = (cell.size.x - bevel) * fraction
draw_line(cell.position + Vector2(bevel, 1), cell.position + Vector2(bevel + length, 1), fill_color.lightened(0.45), 1.0)
draw_line(cell.position + Vector2(0, cell.size.y - 1), cell.position + Vector2(length, cell.size.y - 1), fill_color.darkened(0.4), 1.0)
if activation_ratio >= 0.0:
var marker_x: float = inner.position.x + inner.size.x * clampf(activation_ratio, 0.0, 1.0)
draw_line(Vector2(marker_x, 1), Vector2(marker_x, size.y - 1), Color(0.94, 0.94, 0.79, 0.65), 1.0)
draw_colored_polygon(PackedVector2Array([
Vector2(marker_x, size.y), Vector2(marker_x - 3, size.y + 4), Vector2(marker_x + 3, size.y + 4)
]), Color("e7e7ca"))
if highlighted:
var strength: float = 0.7
if animations_enabled and not Engine.is_editor_hint():
strength = 0.65 + sin(_pulse_phase) * 0.2
draw_rect(Rect2(Vector2(-1, -1), size + Vector2(2, 2)), Color(fill_color, strength), false, 1.0)
if _damage_flash > 0.0 and animations_enabled and not Engine.is_editor_hint():
draw_rect(Rect2(Vector2.ZERO, size), Color(1.0, 0.87, 0.76, _damage_flash * 1.5))
## Recorta cada segmento en diagonal sin texturas adicionales ni shaders.
func _draw_segment(rect: Rect2, fraction: float, color: Color) -> void:
if fraction <= 0.0:
return
var bevel: float = minf(3.0, rect.size.x * 0.25)
var length: float = (rect.size.x - bevel) * fraction
var origin: Vector2 = rect.position
draw_colored_polygon(PackedVector2Array([
origin + Vector2(bevel, 0), origin + Vector2(bevel + length, 0),
origin + Vector2(length, rect.size.y), origin + Vector2(0, rect.size.y)
]), color)
+5
View File
@@ -1,5 +1,7 @@
[gd_scene format=3 uid="uid://g7h185yageqr"]
[ext_resource type="Script" path="res://ui/editor_ui_visibility.gd" id="editor_ui_visibility"]
[ext_resource type="Script" uid="uid://2kbajcohyem7" path="res://ui/mobile_controls/mobile_controls.gd" id="1_controls"]
[ext_resource type="Texture2D" uid="uid://cj6wl2l43nao2" path="res://assets/ui/mobile_controls/left-arrow.png" id="2_left"]
[ext_resource type="Texture2D" uid="uid://y0tsuhk4moj3" path="res://assets/ui/mobile_controls/right-arrow.png" id="3_right"]
@@ -34,6 +36,9 @@ corner_radius_bottom_left = 14
layer = 100
script = ExtResource("1_controls")
[node name="EditorVisibility" type="Node" parent="."]
script = ExtResource("editor_ui_visibility")
[node name="Controls" type="Control" parent="." unique_id=1754744981]
layout_mode = 3
anchors_preset = 15