1634 lines
71 KiB
Diff
1634 lines
71 KiB
Diff
diff --git a/README.md b/README.md
|
|
index 4cccbd412f461e739e24ce15482266ec8bc30382..65088111b986c1d7635ee2aff4abff0a1589d726 100644
|
|
--- a/README.md
|
|
+++ b/README.md
|
|
@@ -67,9 +67,20 @@ python tools/run_checks.py --static-only
|
|
python tools/run_checks.py --godot /ruta/al/ejecutable/godot
|
|
```
|
|
|
|
-El segundo comando importa recursos y ejecuta las cinco suites de motor. La
|
|
+El segundo comando importa recursos y ejecuta todas las suites de motor. La
|
|
primera opcion no ejecuta GDScript ni valida fisica o dibujo en Godot. El resultado
|
|
-de la validacion realizada en esta entrega figura en `docs/reorganization.md`.
|
|
+del kit inicial figura en `docs/reorganization.md`; el cambio posterior de HUD
|
|
+y balance se documenta en `docs/thrash_hud.md`.
|
|
|
|
Para exportar Android se conserva `scripts/export_android_debug.sh` y la
|
|
configuracion original de exportacion. La reorganizacion no incluye una nueva APK.
|
|
+
|
|
+## HUD thrash y editor despejado
|
|
+
|
|
+La interfaz se oculta al montar niveles y se muestra al abrir su escena o jugar.
|
|
+El HUD reutiliza un marco metalico, medidores segmentados y la fuente ya existente.
|
|
+El especial concede 10 puntos por baja normal y, por defecto, no se recarga con
|
|
+sus propias bajas. El minimo de uso permanece en 25 puntos.
|
|
+
|
|
+Consulta `docs/thrash_hud.md` para aplicar el parche, ajustar aspecto/animaciones
|
|
+y comprobar el balance. La ocultacion se explica en `docs/editor_ui_visibility.md`.
|
|
diff --git a/assets/ui/hud/thrash_bolt.svg b/assets/ui/hud/thrash_bolt.svg
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7cc68e8845038028f7e657dd3065e3da7db0ddbb
|
|
--- /dev/null
|
|
+++ b/assets/ui/hud/thrash_bolt.svg
|
|
@@ -0,0 +1,7 @@
|
|
+<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
|
|
+ <path d="M9 5H32L25 16H35L8 39L15 24H5Z" fill="#29382a" stroke="#060a0c" stroke-width="2"/>
|
|
+ <path d="M10 3H30L22 16H32L11 35L17 22H7Z" fill="#bde345"/>
|
|
+ <path d="M10 3H30L27 7H13L10 18H20L16 27L11 35L17 22H7Z" fill="#ecf5a1"/>
|
|
+ <path d="M22 16H32L28 20H20Z" fill="#6f9c26"/>
|
|
+ <path d="M3 9L1 16M36 23L39 18M30 33L35 29" stroke="#667c40" stroke-width="2"/>
|
|
+</svg>
|
|
diff --git a/assets/ui/hud/thrash_plate.svg b/assets/ui/hud/thrash_plate.svg
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..459ac8f732add98aeccdf2c05d7434a14c3078c2
|
|
--- /dev/null
|
|
+++ b/assets/ui/hud/thrash_plate.svg
|
|
@@ -0,0 +1,32 @@
|
|
+<svg xmlns="http://www.w3.org/2000/svg" width="344" height="64" viewBox="0 0 344 64">
|
|
+ <defs>
|
|
+ <linearGradient id="steel" x2="0" y2="1">
|
|
+ <stop stop-color="#b3b8b5"/>
|
|
+ <stop offset=".16" stop-color="#414b51"/>
|
|
+ <stop offset=".53" stop-color="#20272c"/>
|
|
+ <stop offset="1" stop-color="#697275"/>
|
|
+ </linearGradient>
|
|
+ <linearGradient id="panel" x2="0" y2="1">
|
|
+ <stop stop-color="#252b30"/>
|
|
+ <stop offset="1" stop-color="#111519"/>
|
|
+ </linearGradient>
|
|
+ </defs>
|
|
+ <path d="M12 2H59L67 7H328L344 22V54L334 64H60L51 59H12L0 47V14Z" fill="#05070a"/>
|
|
+ <path d="M12 0H59L67 5H327L342 20V52L332 62H60L51 57H12L0 45V12Z" fill="url(#steel)"/>
|
|
+ <path d="M13 2H58L66 7H326L340 21V51L331 60H61L52 55H13L2 44V13Z" fill="url(#panel)"/>
|
|
+ <path d="M64 10H323L335 22V51L329 56H64Z" fill="#101519"/>
|
|
+ <path d="M14 5H48L57 14V44L48 52H14L6 43V14Z" fill="#080c10" stroke="#5e686c"/>
|
|
+ <path d="M9 16L17 8H47M65 9H321L331 19" fill="none" stroke="#89918a" stroke-opacity=".42"/>
|
|
+ <path d="M168 56H327M59 14V48" fill="none" stroke="#000" stroke-width="2"/>
|
|
+ <path d="M251 58H296M305 58H325" stroke="#89918a" stroke-opacity=".34"/>
|
|
+ <path d="M18 3L26 3M284 7L290 9M305 7L309 9M335 43L339 39M9 48L14 50" stroke="#c4c4b2" stroke-opacity=".38"/>
|
|
+ <g fill="#a4aaa1" stroke="#090d10" stroke-width="1">
|
|
+ <path d="M7 8L10 5L13 8L10 11Z"/>
|
|
+ <path d="M49 8L52 5L55 8L52 11Z"/>
|
|
+ <path d="M7 48L10 45L13 48L10 51Z"/>
|
|
+ <path d="M49 48L52 45L55 48L52 51Z"/>
|
|
+ <path d="M332 25L335 22L338 25L335 28Z"/>
|
|
+ <path d="M332 49L335 46L338 49L335 52Z"/>
|
|
+ </g>
|
|
+ <path d="M9 8H11M51 8H53M9 48H11M51 48H53M334 25H336M334 49H336" stroke="#303a3e"/>
|
|
+</svg>
|
|
diff --git a/assets/ui/hud/thrash_skull.svg b/assets/ui/hud/thrash_skull.svg
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..13e687476ac1f47720dcb39ce3e5f60fe3433e08
|
|
--- /dev/null
|
|
+++ b/assets/ui/hud/thrash_skull.svg
|
|
@@ -0,0 +1,11 @@
|
|
+<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
|
|
+ <path d="M8 10L0 2L3 17L10 23M32 10L40 2L37 17L30 23" fill="#78817d"/>
|
|
+ <path d="M12 4L20 1L29 4L34 11L33 25L28 29L27 37H13L12 29L7 25L6 12Z" fill="#7e8986"/>
|
|
+ <path d="M12 4L20 2L28 5L32 12L31 24L26 28L25 34H15L14 28L9 24L8 12Z" fill="#e3dfbd"/>
|
|
+ <path d="M11 15L18 17L17 23L11 21ZM29 15L22 17L23 23L29 21Z" fill="#121518"/>
|
|
+ <path d="M14 18L17 19L16 21L13 20M23 19L26 18L27 20L24 21" fill="#ce3440"/>
|
|
+ <path d="M20 22L17 27H23Z" fill="#171b1d"/>
|
|
+ <path d="M16 30V35M20 29V36M24 30V35" stroke="#171b1d" stroke-width="2"/>
|
|
+ <path d="M19 3L17 9L21 12L18 15" fill="none" stroke="#858e86"/>
|
|
+ <path d="M11 8L15 6M25 7L28 10" stroke="#fff7da"/>
|
|
+</svg>
|
|
diff --git a/docs/architecture.md b/docs/architecture.md
|
|
index 5bd1f8b3875bdf20ebef8312ddd395e432b94a1e..14744f6f54ca15632a30808322b4ec016bda2a3e 100644
|
|
--- a/docs/architecture.md
|
|
+++ b/docs/architecture.md
|
|
@@ -139,3 +139,19 @@ aunque algunos esten en espanol, para no romper recursos ni registros anteriores
|
|
No se ha traducido ni reformateado el addon externo. Modificar sus fuentes solo
|
|
para igualar comentarios dificultaria actualizarlo y mezclar cambios propios con
|
|
los del proveedor.
|
|
+
|
|
+## Presentacion del HUD
|
|
+
|
|
+- `ui/editor_ui_visibility.gd`: visibilidad de cada CanvasLayer segun se edite un
|
|
+ nivel, la propia UI o se ejecute el juego. No contiene logica de combate.
|
|
+- `ui/hud/thrash_meter.gd`: ProgressBar visual compartida, con segmentos, estela,
|
|
+ marca del minimo y animacion opcional. Es @tool para previsualizarla.
|
|
+- `ui/hud/player_health_hud.gd` y `special_charge_hud.gd`: conectan las senales del
|
|
+ jugador con textos y medidores. No se ejecutan dentro del editor.
|
|
+- `ui/hud/thrash_hud_theme.tres` y `assets/ui/hud/`: tipografia, marco e iconos.
|
|
+
|
|
+La economia del especial permanece exclusivamente en `player/player.gd`. El HUD
|
|
+no concede ni consume carga. `_applying_special_damage` delimita la llamada
|
|
+sincronica a `take_damage`; el Walker actual emite `died` antes de devolverla.
|
|
+Si en el futuro se retrasa esa senal o se anaden danos persistentes, habra que
|
|
+transportar la causa del dano en la recompensa en lugar de ampliar este contexto.
|
|
diff --git a/docs/editor_ui_visibility.md b/docs/editor_ui_visibility.md
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..f9553b40f7ac1597210dbfa7922efb560ebef767
|
|
--- /dev/null
|
|
+++ b/docs/editor_ui_visibility.md
|
|
@@ -0,0 +1,99 @@
|
|
+# Interfaz oculta mientras se construyen niveles
|
|
+
|
|
+## Comportamiento del cambio
|
|
+
|
|
+El componente `ui/editor_ui_visibility.gd` es un nodo auxiliar llamado
|
|
+`EditorVisibility`, hijo directo de cada CanvasLayer de interfaz.
|
|
+
|
|
+- Dentro de un nivel o de la escena del personaje oculta esa capa en el editor.
|
|
+- Al abrir directamente la escena de esa interfaz, la muestra para editarla.
|
|
+- Al iniciar la partida muestra la capa aunque se haya guardado oculta.
|
|
+- Una vez iniciada la partida deja de procesar. El juego puede ocultar la
|
|
+ interfaz normalmente y los mensajes ocultos individualmente siguen ocultos.
|
|
+
|
|
+El componente de visibilidad no mueve ni redimensiona controles. Los scripts
|
|
+del jugador, HUD y controles tactiles no se convierten en @tool. El nuevo
|
|
+componente visual ThrashMeter tambien usa @tool para mostrar su diseno, pero
|
|
+no ejecuta combate ni entradas dentro del editor.
|
|
+
|
|
+## Aplicacion
|
|
+
|
|
+La ocultacion ya esta incluida en `mortal_maze_thrash_hud.patch`, junto al HUD
|
|
+nuevo y al balance de carga. Este parche parte del proyecto con el kit de niveles
|
|
+aplicado y SIN el parche anterior de ocultacion. No apliques ambos parches.
|
|
+
|
|
+Con Godot cerrado, desde la raiz del repositorio:
|
|
+
|
|
+```sh
|
|
+git apply --check /ruta/mortal_maze_thrash_hud.patch
|
|
+git apply /ruta/mortal_maze_thrash_hud.patch
|
|
+```
|
|
+
|
|
+Si la comprobacion falla, no fuerces la aplicacion ni sustituyas escenas enteras.
|
|
+Consulta el diff para conservar tus ediciones locales.
|
|
+
|
|
+## Conexion manual para no reemplazar niveles ya editados
|
|
+
|
|
+Despues de copiar `ui/editor_ui_visibility.gd` al proyecto, se necesita
|
|
+un Node llamado `EditorVisibility` como hijo directo de cada CanvasLayer
|
|
+que quieras ocultar mientras montas el escenario. Asigna a ese Node el script
|
|
+`res://ui/editor_ui_visibility.gd`.
|
|
+
|
|
+En las tres escenas de UI, el padre es su nodo raiz:
|
|
+
|
|
+- `ui/hud/player_health_hud.tscn`
|
|
+- `ui/hud/special_charge_hud.tscn`
|
|
+- `ui/mobile_controls/mobile_controls.tscn`
|
|
+
|
|
+En los niveles existentes, los padres son:
|
|
+
|
|
+- `levels/level_01.tscn`: nodo `TestHUD`.
|
|
+- `levels/level_02.tscn`: nodo `LevelHUD`.
|
|
+
|
|
+La plantilla, el catalogo, las pruebas de combate y los niveles nuevos que
|
|
+instancien esas escenas de jugador/controles reciben el cambio sin modificar
|
|
+sus propios archivos. Las capas de UI nuevas necesitan su propio componente.
|
|
+
|
|
+## Editar la interfaz
|
|
+
|
|
+Abre directamente cualquiera de las tres escenas de UI anteriores. Se muestra
|
|
+su diseno aunque permanezca oculto cuando se instancia dentro de un nivel.
|
|
+
|
|
+Para ver el HUD que esta definido directamente en `level_01` o `level_02`,
|
|
+selecciona `TestHUD/EditorVisibility` o `LevelHUD/EditorVisibility` y activa
|
|
+`Preview In Editor` en el Inspector. Desactivalo al terminar.
|
|
+
|
|
+El mismo ajuste permite previsualizar las otras capas dentro del nivel.
|
|
+Para cambiarlo por instancia puedes habilitar los hijos editables de esa
|
|
+instancia y seleccionar su nodo `EditorVisibility`. Cambiarlo en la escena
|
|
+original afecta a todas sus instancias que no lo sobrescriban.
|
|
+
|
|
+No uses el ojo del CanvasLayer como ajuste permanente del editor: este
|
|
+componente gestiona su visibilidad. Para ocultar la interfaz durante la partida,
|
|
+la logica del juego puede llamar a hide() despues de entrar en el arbol.
|
|
+El componente no vuelve a mostrarla cada frame mientras juegas.
|
|
+
|
|
+## Verificacion realizada y pendiente
|
|
+
|
|
+El registro de esta entrega esta en `docs/thrash_hud.md`. Se han ejecutado las
|
|
+49 pruebas estaticas, incluida la conexion de estas cinco capas. El redisenado
|
|
+del HUD cambia sus escenas y controladores; la logica de controles tactiles y
|
|
+los scripts de los niveles siguen sin cambios.
|
|
+
|
|
+No se ha podido ejecutar Godot aqui. La prueba `tests/test_editor_ui_runtime.gd`
|
|
+y la nueva `tests/test_thrash_hud_runtime.gd` estan incluidas, pero pendientes.
|
|
+
|
|
+```sh
|
|
+python tools/run_checks.py --godot /ruta/al/ejecutable/godot
|
|
+```
|
|
+
|
|
+La comprobacion visual pendiente es abrir un nivel (UI oculta), abrir una escena
|
|
+de UI por separado (UI visible), volver al nivel (UI oculta) y ejecutar el nivel
|
|
+(HUD y controles visibles). Repite despues de guardar para comprobar tambien
|
|
+que una capa serializada como oculta reaparece correctamente durante el juego.
|
|
+
|
|
+## Referencias de Godot
|
|
+
|
|
+- https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html
|
|
+- https://docs.godotengine.org/en/stable/classes/class_canvaslayer.html
|
|
+- https://docs.godotengine.org/en/stable/classes/class_scenetree.html
|
|
diff --git a/docs/thrash_hud.md b/docs/thrash_hud.md
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..79c4313b9111726b191b0adda94fbf3ffbb591e4
|
|
--- /dev/null
|
|
+++ b/docs/thrash_hud.md
|
|
@@ -0,0 +1,160 @@
|
|
+# HUD thrash, editor despejado y carga del especial
|
|
+
|
|
+## Base y aplicacion del parche
|
|
+
|
|
+`mortal_maze_thrash_hud.patch` se aplica sobre el proyecto original con la
|
|
+reorganizacion `mortal_maze_level_kit_changes.zip` ya integrada, pero SIN haber
|
|
+aplicado `mortal_maze_editor_ui.patch`. Ya contiene ese cambio de ocultacion.
|
|
+
|
|
+Guarda o confirma tus cambios y cierra Godot. Desde la raiz del repositorio,
|
|
+con el parche descargado en esa carpeta:
|
|
+
|
|
+```sh
|
|
+git apply --check mortal_maze_thrash_hud.patch
|
|
+git apply mortal_maze_thrash_hud.patch
|
|
+git diff --check
|
|
+```
|
|
+
|
|
+El primer comando no modifica archivos. Si detecta conflictos, no lo fuerces:
|
|
+compara los bloques afectados con tus ediciones. El parche no sustituye carpetas
|
|
+completas, no incluye fuentes tipograficas ni caches y no modifica el addon.
|
|
+Reabre el proyecto y deja terminar la importacion de los nuevos SVG y scripts.
|
|
+
|
|
+## Cambios visibles
|
|
+
|
|
+El conjunto ocupa 344 x 132 px con margen de 18 px en la esquina superior
|
|
+izquierda. No se cambian la resolucion, el escalado del proyecto ni los botones
|
|
+tactiles. Los textos de mejoras temporales comienzan debajo de ambas barras.
|
|
+
|
|
+La vida usa una placa oscura con remaches, calavera y segmentos rojos. El numero
|
|
+refleja la vida real inmediatamente; la parte perdida queda un instante en color
|
|
+hueso antes de desaparecer. Al 25% de vida o menos aparece PELIGRO y un pulso lento.
|
|
+Con vida cero se muestra SIN VIDA, sin mantener el aviso animado de peligro.
|
|
+
|
|
+El solo usa el mismo marco con un rayo y segmentos verde acido. Hay una marca
|
|
+sobre el umbral real de uso, una leyenda de puntos minimos y tres estados:
|
|
+
|
|
+| Estado | Significado |
|
|
+|---|---|
|
|
+| CARGANDO | Todavia no hay carga suficiente |
|
|
+| LISTO | Se ha alcanzado el minimo de carga |
|
|
+| AL 11 | La capacidad esta completa |
|
|
+| DESACTIVADO | Capacidad cero o minimo configurado por encima de la capacidad |
|
|
+
|
|
+LISTO se refiere a la energia, no anula las restricciones temporales del combate.
|
|
+La carga sube suavemente, pero al gastarla la barra se vacia inmediatamente para
|
|
+no aparentar energia utilizable. No se anaden sonidos, combos ni ataques nuevos.
|
|
+
|
|
+El diseno se apoya en tres SVG de texto y la fuente que ya habia en el proyecto.
|
|
+No necesita shaders, plugins nuevos, servicios externos ni archivos de fuentes
|
|
+adicionales. La logica de combate no se ejecuta dentro del editor.
|
|
+
|
|
+## Balance
|
|
+
|
|
+| Ajuste | Antes | Ahora |
|
|
+|---|---:|---:|
|
|
+| Capacidad inicial | 100 | 100 |
|
|
+| Puntos por baja ordinaria | 25 | 10 |
|
|
+| Minimo para usar el solo | 25 | 25 |
|
|
+| Bajas para poder usarlo desde cero, sin objetos | 1 | 3 |
|
|
+| Bajas para llenarlo desde cero, sin objetos | 4 | 10 |
|
|
+| Recarga por bajas causadas por el propio solo | Si | No, configurable |
|
|
+
|
|
+Se sigue consumiendo toda la carga acumulada y el dano sigue escalando con ella.
|
|
+No es necesario esperar al 100%: con tres bajas tendras 30 puntos y podras usarlo,
|
|
+pero con menos potencia que con la barra llena. Dano maximo, radio, duracion,
|
|
+numero de pulsos, movimiento y salto permanecen como estaban.
|
|
+
|
|
+Los objetos de recarga mantienen sus valores: casete 25, setlist 50 y amplificador
|
|
+100. Por tanto, las diez bajas son la referencia SIN objetos. No se retocan los
|
|
+drops ni su frecuencia. Es un punto de partida para probar jugando, no un balance
|
|
+validado mediante partidas en este entorno.
|
|
+
|
|
+La opcion `special_kills_grant_charge` filtra solo las muertes causadas por la
|
|
+llamada de dano del solo. Una baja normal que coincida con su animacion sigue
|
|
+otorgando puntos. Se aprovecha que Walker emite `died` dentro de `take_damage`;
|
|
+si se introduce dano diferido, habra que transmitir su procedencia explicitamente.
|
|
+
|
|
+## Ajustes sin codigo
|
|
+
|
|
+En la raiz de `player/player.tscn`, categoria **Special Attack**:
|
|
+
|
|
+```text
|
|
+Special Max Charge 100
|
|
+Special Charge Per Kill 10
|
|
+Special Min Use Charge 25
|
|
+Special Kills Grant Charge false
|
|
+```
|
|
+
|
|
+Poner el minimo a 100 obliga a llenar la barra. Activar la ultima opcion recupera
|
|
+la recarga con bajas propias. Las sobrescrituras de una instancia de Player tienen
|
|
+prioridad sobre el valor de su escena original, como el resto de sus parametros.
|
|
+
|
|
+Para editar el diseno abre estas escenas directamente:
|
|
+
|
|
+```text
|
|
+ui/hud/player_health_hud.tscn
|
|
+ui/hud/special_charge_hud.tscn
|
|
+```
|
|
+
|
|
+En `HUD/HealthBar` o `HUD/SpecialBar`:
|
|
+
|
|
+| Propiedad | Para que sirve |
|
|
+|---|---|
|
|
+| Fill Color | Color de los segmentos |
|
|
+| Segment Count | Numero de segmentos; no cambia la vida o la carga |
|
|
+| Animations Enabled | Desactiva pulsos, estelas animadas y transiciones |
|
|
+| Show Damage Trail | Presenta temporalmente la energia perdida; desactivado en el solo |
|
|
+| Damage Trail Delay | Tiempo de espera antes de reducir la estela |
|
|
+| Fill Transition Seconds | Duracion de cada subida visual de vida/carga |
|
|
+
|
|
+`Activation Ratio` muestra una marca de maqueta en el editor; durante la partida
|
|
+lo calcula el controlador con los valores reales del jugador. No debe utilizarse
|
|
+como configuracion del coste del ataque. `value` y `max_value` de las escenas de UI
|
|
+tambien son muestras: el jugador proporciona la lectura inicial al empezar.
|
|
+
|
|
+En la raiz de `PlayerHealthHUD`, `Low Health Ratio` ajusta el umbral de PELIGRO.
|
|
+El tema comun esta en `ui/hud/thrash_hud_theme.tres`; los textos, posiciones y
|
|
+anclajes siguen siendo nodos editables. Cada barra es una escena reutilizable.
|
|
+
|
|
+## Ocultacion al disenar niveles
|
|
+
|
|
+El parche incluye `EditorVisibility` en vida, especial, controles tactiles y
|
|
+los mensajes superpuestos de Level01/Level02. Esas capas se ocultan al construir
|
|
+un escenario; se muestran al abrir su propia escena o al jugar. Los carteles del
|
|
+mapa no se ocultan. El control de visibilidad no interfiere con paneles que deban
|
|
+permanecer ocultos durante la partida.
|
|
+
|
|
+`Preview In Editor` permite revisar una capa sin salir del nivel. Consulta
|
|
+`docs/editor_ui_visibility.md` para editar ese ajuste por instancia.
|
|
+
|
|
+## Comprobaciones
|
|
+
|
|
+Realizado en esta entrega:
|
|
+
|
|
+- Las 49 pruebas estaticas de Python pasan. Incluyen recursos, conexiones de UI,
|
|
+ rutas, aislamiento de entradas y contratos del nuevo balance.
|
|
+- Se revisaron los SVG y la geometria con un render de referencia externo a Godot.
|
|
+ Ese render no valida el motor, sus fuentes, animaciones ni la experiencia jugable.
|
|
+- Se comprobo la aplicacion del parche sobre una reconstruccion limpia de su base,
|
|
+ la coincidencia del resultado con los archivos entregados y su reversibilidad.
|
|
+
|
|
+No se ha podido ejecutar Godot. La importacion real, las siete suites de motor,
|
|
+la ocultacion interactiva, las animaciones y la validacion en Android quedan
|
|
+pendientes. No se ha generado ni probado una APK. No se debe interpretar que
|
|
+las pruebas estaticas compilan o ejecutan GDScript.
|
|
+
|
|
+```sh
|
|
+python tools/run_checks.py --static-only
|
|
+python tools/run_checks.py --godot /ruta/al/ejecutable/godot
|
|
+```
|
|
+
|
|
+El segundo comando importa y descubre automaticamente todas las suites. La nueva
|
|
+`tests/test_thrash_hud_runtime.gd` cubre vida inicial, perdida y curacion, modo sin
|
|
+animaciones, carga por baja, saturacion, umbrales configurables, consumo, capacidad
|
|
+cero, bajas reales por el solo y conservacion de objetos de recarga.
|
|
+
|
|
+Para la revision visual, abre un nivel, abre luego cada escena de UI y ejecuta
|
|
+el nivel con F6. Comprueba recibir dano, curarte, reunir tres y diez bajas sin
|
|
+objetos y gastar el especial. Revisa tambien la composicion en los tamanos de
|
|
+pantalla que utilices, sobre todo con controles tactiles.
|
|
diff --git a/docs/tuning.md b/docs/tuning.md
|
|
index b55d9df716d584e6aeecb78fd4511de367056aa8..63bcb85ba8af8401fe2222ad8a66d1939646cf46 100644
|
|
--- a/docs/tuning.md
|
|
+++ b/docs/tuning.md
|
|
@@ -49,7 +49,7 @@ sobrescrituras locales. No hace falta buscar una constante dentro del controlado
|
|
| Damage received | Invulnerabilidad e impulso al recibir dano |
|
|
| Punch | Preparacion, duracion activa, espera, tamano y desplazamiento del area |
|
|
| Ground Pound | Velocidad de inicio, gravedad, control horizontal, radio y limites de dano |
|
|
-| Special Attack | Capacidad, carga por muerte, minimo de uso, radio, dano, duracion y pulsos |
|
|
+| Special Attack | Capacidad, carga por muerte, recarga con bajas del solo, minimo de uso, radio, dano, duracion y pulsos |
|
|
| Debug | Dibujo de colisiones y duracion del indicador de impacto |
|
|
|
|
La altura real de salto depende de `jump_velocity`, gravedad, corte al soltar y
|
|
@@ -73,6 +73,33 @@ creado un segundo valor global que la sustituya.
|
|
player.tscn no elimina esas excepciones. El
|
|
Inspector permite restablecer una propiedad al valor heredado cuando corresponde.
|
|
|
|
+## Carga del especial y aspecto del HUD
|
|
+
|
|
+Los ajustes siguen en la raiz de `player/player.tscn`, categoria **Special Attack**:
|
|
+
|
|
+| Propiedad | Valor inicial | Efecto |
|
|
+|---|---:|---|
|
|
+| `special_max_charge` | 100 | Capacidad en puntos; cero desactiva el ataque |
|
|
+| `special_charge_per_kill` | 10 | Recompensa por una baja ordinaria |
|
|
+| `special_min_use_charge` | 25 | Minimo de activacion; el solo consume toda la carga acumulada |
|
|
+| `special_kills_grant_charge` | false | Activar para que las bajas del propio solo vuelvan a recargarlo |
|
|
+
|
|
+Desde cero y sin recoger objetos: dos bajas suman 20 y no permiten usarlo; tres
|
|
+suman 30 y si permiten; diez llenan los 100 puntos. El dano sigue dependiendo de
|
|
+la carga consumida, igual que antes. Los objetos de recarga conservan 25/50/100
|
|
+puntos segun su recurso; no se han modificado sus probabilidades de aparicion.
|
|
+
|
|
+El HUD lee capacidad y minimo del jugador; no hay que sincronizar otros valores.
|
|
+El texto `MIN 25 PT` son puntos, mientras el numero grande muestra el porcentaje
|
|
+respecto a la capacidad configurada. `LISTO` significa carga suficiente, no que
|
|
+se anulen bloqueos temporales como estar ejecutando otro ataque.
|
|
+
|
|
+Para editar el aspecto abre las escenas de `ui/hud/` directamente. En `HUD/HealthBar`
|
|
+o `HUD/SpecialBar`, **Thrash Appearance** ajusta color y segmentos, y **Thrash Feedback**
|
|
+permite desactivar las animaciones. En la raiz del HUD de vida, **Low Health Ratio**
|
|
+controla el aviso de peligro sin alterar la vida del personaje. Mas detalles en
|
|
+`docs/thrash_hud.md`.
|
|
+
|
|
## Camara y controles
|
|
|
|
Los limites del mapa estan en `Camera Bounds` de la raiz de cada nivel. El zoom
|
|
diff --git a/levels/level_01.tscn b/levels/level_01.tscn
|
|
index 415fd2d2748398b2aaa3b99e56f404f92a9bc572..7e66cddf27e163fd8dcdd3bdaf453949831e6b90 100644
|
|
--- a/levels/level_01.tscn
|
|
+++ b/levels/level_01.tscn
|
|
@@ -1,4 +1,6 @@
|
|
-[gd_scene load_steps=31 format=3]
|
|
+[gd_scene load_steps=32 format=3]
|
|
+
|
|
+[ext_resource type="Script" path="res://ui/editor_ui_visibility.gd" id="editor_ui_visibility"]
|
|
|
|
[ext_resource type="PackedScene" path="res://world/terrain/solid_block.tscn" id="kit_solid_block"]
|
|
|
|
@@ -438,6 +440,9 @@ shape = SubResource("DeathShape")
|
|
[node name="TestHUD" type="CanvasLayer" parent="."]
|
|
layer = 87
|
|
|
|
+[node name="EditorVisibility" type="Node" parent="TestHUD"]
|
|
+script = ExtResource("editor_ui_visibility")
|
|
+
|
|
[node name="Overlay" type="Control" parent="TestHUD"]
|
|
layout_mode = 3
|
|
anchors_preset = 15
|
|
diff --git a/levels/level_02.tscn b/levels/level_02.tscn
|
|
index 74fb16b34327494e33022e34a99b81b99acd786b..d0c9713f8b214558643a1dfdf07053e198d378d4 100644
|
|
--- a/levels/level_02.tscn
|
|
+++ b/levels/level_02.tscn
|
|
@@ -1,4 +1,6 @@
|
|
-[gd_scene load_steps=38 format=3]
|
|
+[gd_scene load_steps=39 format=3]
|
|
+
|
|
+[ext_resource type="Script" path="res://ui/editor_ui_visibility.gd" id="editor_ui_visibility"]
|
|
|
|
[ext_resource type="PackedScene" path="res://world/backgrounds/city_background.tscn" id="kit_background"]
|
|
|
|
@@ -565,6 +567,9 @@ text = "FIN DE LA GIRA!"
|
|
[node name="LevelHUD" type="CanvasLayer" parent="."]
|
|
layer = 87
|
|
|
|
+[node name="EditorVisibility" type="Node" parent="LevelHUD"]
|
|
+script = ExtResource("editor_ui_visibility")
|
|
+
|
|
[node name="Overlay" type="Control" parent="LevelHUD"]
|
|
layout_mode = 3
|
|
anchors_preset = 15
|
|
diff --git a/player/player.gd b/player/player.gd
|
|
index de975b2a8794c54ab93936e9537a889a2fc4e9b7..b940b8b306803e5a6984dcb3d1666d99a9c02ecc 100644
|
|
--- a/player/player.gd
|
|
+++ b/player/player.gd
|
|
@@ -154,8 +154,12 @@ const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
|
## Capacidad maxima del medidor especial, entre 0 y 100.
|
|
@export_range(0, 100, 1) var special_max_charge: int = 100
|
|
|
|
-## Carga que se concede al recibir la senal de muerte de un enemigo.
|
|
-@export_range(0, 100, 1) var special_charge_per_kill: int = 25
|
|
+## Puntos por baja: con capacidad 100, diez bajas llenan el medidor desde cero.
|
|
+@export_range(0, 100, 1) var special_charge_per_kill: int = 10
|
|
+
|
|
+## Desactivado evita que el solo se pague a si mismo al eliminar grupos de enemigos.
|
|
+## Solo filtra bajas causadas por su dano, no otras muertes que coincidan durante el solo.
|
|
+@export var special_kills_grant_charge: bool = false
|
|
|
|
## Carga minima necesaria para iniciar el ataque especial.
|
|
@export_range(0, 100, 1) var special_min_use_charge: int = 25
|
|
@@ -244,6 +248,8 @@ var punch_hit_targets: Dictionary = {}
|
|
var special_charge: int = 0
|
|
|
|
var _special_active: bool = false
|
|
+# Contexto sincronico del dano: Walker emite died dentro de take_damage.
|
|
+var _applying_special_damage: bool = false
|
|
var _special_elapsed: float = 0.0
|
|
var _special_charge_used: int = 0
|
|
var _special_pulses_sent: int = 0
|
|
@@ -625,7 +631,9 @@ func _apply_special_attack(charge_used: int, pulse_index: int = 0) -> void:
|
|
if damage <= 0:
|
|
continue
|
|
_special_damage_dealt[enemy_id] = cumulative_damage
|
|
+ _applying_special_damage = true
|
|
enemy.call("take_damage", damage, global_position)
|
|
+ _applying_special_damage = false
|
|
|
|
|
|
## Devuelve true solo si se aplica el efecto. False conserva el objeto para otra oportunidad.
|
|
@@ -715,7 +723,7 @@ func _connect_to_enemies() -> void:
|
|
|
|
## Suma carga sin superar su capacidad maxima y notifica al HUD.
|
|
func _on_enemy_died(_enemy: Node) -> void:
|
|
- if is_dead:
|
|
+ if is_dead or (_applying_special_damage and not special_kills_grant_charge):
|
|
return
|
|
|
|
special_charge = min(special_charge + special_charge_per_kill, special_max_charge)
|
|
diff --git a/tests/test_editor_ui_resources.py b/tests/test_editor_ui_resources.py
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3970206c80a11a51dd6e3798ad5a0b2df07bcd3d
|
|
--- /dev/null
|
|
+++ b/tests/test_editor_ui_resources.py
|
|
@@ -0,0 +1,54 @@
|
|
+"""Contratos de conexion de la visibilidad de UI; no sustituyen al motor."""
|
|
+
|
|
+from pathlib import Path
|
|
+import re
|
|
+import unittest
|
|
+
|
|
+ROOT = Path(__file__).resolve().parents[1]
|
|
+UI_SCENES = {
|
|
+ "ui/hud/player_health_hud.tscn": ".",
|
|
+ "ui/hud/special_charge_hud.tscn": ".",
|
|
+ "ui/mobile_controls/mobile_controls.tscn": ".",
|
|
+ "levels/level_01.tscn": "TestHUD",
|
|
+ "levels/level_02.tscn": "LevelHUD",
|
|
+}
|
|
+
|
|
+
|
|
+class EditorUIResourceTests(unittest.TestCase):
|
|
+ def test_each_existing_overlay_has_a_visibility_component(self):
|
|
+ for relative, parent in UI_SCENES.items():
|
|
+ with self.subTest(scene=relative):
|
|
+ text = (ROOT / relative).read_text(encoding="utf-8")
|
|
+ self.assertIn('path="res://ui/editor_ui_visibility.gd"', text)
|
|
+ self.assertIn(
|
|
+ f'[node name="EditorVisibility" type="Node" parent="{parent}"]\n'
|
|
+ 'script = ExtResource("editor_ui_visibility")', text,
|
|
+ )
|
|
+
|
|
+ def test_gameplay_ui_scripts_do_not_run_inside_the_editor(self):
|
|
+ for relative in (
|
|
+ "ui/hud/player_health_hud.gd",
|
|
+ "ui/hud/special_charge_hud.gd",
|
|
+ "ui/mobile_controls/mobile_controls.gd",
|
|
+ "player/player.gd",
|
|
+ ):
|
|
+ with self.subTest(script=relative):
|
|
+ self.assertNotIn("@tool", (ROOT / relative).read_text(encoding="utf-8"))
|
|
+
|
|
+ def test_component_is_editor_aware_and_does_not_move_ui(self):
|
|
+ text = (ROOT / "ui/editor_ui_visibility.gd").read_text(encoding="utf-8")
|
|
+ self.assertTrue(text.startswith("@tool\n"))
|
|
+ self.assertIn("func _ready() -> void:\n\tset_process(Engine.is_editor_hint())", text)
|
|
+ self.assertIn("edited_scene_root == canvas_layer", text)
|
|
+ self.assertIn("@export var preview_in_editor: bool = false", text)
|
|
+ for property_name in ("position", "offset", "scale", "rotation", "layer"):
|
|
+ self.assertNotRegex(text, rf"canvas_layer\.{property_name}\s*=")
|
|
+
|
|
+ def test_component_does_not_modify_child_visibility(self):
|
|
+ text = (ROOT / "ui/editor_ui_visibility.gd").read_text(encoding="utf-8")
|
|
+ self.assertEqual(re.findall(r"^\s*(\w+)\.visible\s*=", text, re.MULTILINE), ["canvas_layer"])
|
|
+ self.assertNotIn("get_children()", text)
|
|
+
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ unittest.main()
|
|
diff --git a/tests/test_editor_ui_runtime.gd b/tests/test_editor_ui_runtime.gd
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..caf86d664d7123c66828dd050693d2be307a6540
|
|
--- /dev/null
|
|
+++ b/tests/test_editor_ui_runtime.gd
|
|
@@ -0,0 +1,47 @@
|
|
+extends SceneTree
|
|
+
|
|
+## Ejecutar despues de importar el proyecto, igual que las otras suites.
|
|
+## Comprueba restauracion, visibilidad de hijos y ausencia de interferencia al jugar.
|
|
+## La previsualizacion en el editor se debe comprobar tambien abriendo las escenas.
|
|
+
|
|
+const VISIBILITY_SCRIPT: Script = preload("res://ui/editor_ui_visibility.gd")
|
|
+var _failures: int = 0
|
|
+
|
|
+
|
|
+func _initialize() -> void:
|
|
+ call_deferred("_run")
|
|
+
|
|
+
|
|
+func _run() -> void:
|
|
+ var canvas_layer := CanvasLayer.new()
|
|
+ canvas_layer.visible = false
|
|
+ var panel := Control.new()
|
|
+ canvas_layer.add_child(panel)
|
|
+ var hidden_message := Label.new()
|
|
+ hidden_message.visible = false
|
|
+ panel.add_child(hidden_message)
|
|
+ var visibility := Node.new()
|
|
+ visibility.set_script(VISIBILITY_SCRIPT)
|
|
+ canvas_layer.add_child(visibility)
|
|
+ root.add_child(canvas_layer)
|
|
+ await process_frame
|
|
+ _check(canvas_layer.visible, "La interfaz debe reaparecer al ejecutar una escena guardada oculta")
|
|
+ _check(panel.is_visible_in_tree(), "Los controles normales deben seguir visibles al jugar")
|
|
+ _check(not hidden_message.visible, "No se deben mostrar mensajes o paneles ocultos individualmente")
|
|
+ _check(not visibility.is_processing(), "El componente no debe procesar cada frame de la partida")
|
|
+ canvas_layer.hide()
|
|
+ visibility.set("preview_in_editor", true)
|
|
+ await process_frame
|
|
+ await process_frame
|
|
+ _check(not canvas_layer.visible, "El juego debe poder ocultar su UI sin que el componente la reactive")
|
|
+ canvas_layer.queue_free()
|
|
+ await process_frame
|
|
+ if _failures == 0:
|
|
+ print("OK EDITOR UI: restauracion, hijos y visibilidad de partida")
|
|
+ quit(0 if _failures == 0 else 1)
|
|
+
|
|
+
|
|
+func _check(condition: bool, message: String) -> void:
|
|
+ if not condition:
|
|
+ _failures += 1
|
|
+ push_error(message)
|
|
diff --git a/tests/test_pixel_combat_runtime.gd b/tests/test_pixel_combat_runtime.gd
|
|
index 1de2f28afd968369d3c68bc51ff78cc258e8c0e3..277cf0e73dd3745a8490079ba806c868e01e3466 100644
|
|
--- a/tests/test_pixel_combat_runtime.gd
|
|
+++ b/tests/test_pixel_combat_runtime.gd
|
|
@@ -90,7 +90,7 @@ func _run() -> void:
|
|
_check(_death_signals == 1, "Death signal must fire once")
|
|
enemy.call("take_damage", 1000, player.global_position)
|
|
_check(_death_signals == 1, "Repeated hits must not produce another death")
|
|
- _check(int(player.get("special_charge")) == mini(100, charge_before_death + 25),
|
|
+ _check(int(player.get("special_charge")) == mini(int(player.get("special_max_charge")), charge_before_death + int(player.get("special_charge_per_kill"))),
|
|
"Death must grant special charge exactly once")
|
|
enemy.call("_update_death_animation", 0.20)
|
|
var enemy_visual: Sprite2D = enemy.get_node("Visual") as Sprite2D
|
|
diff --git a/tests/test_thrash_hud_resources.py b/tests/test_thrash_hud_resources.py
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c0111c1e16ba299713782f918ecf23bc750fa883
|
|
--- /dev/null
|
|
+++ b/tests/test_thrash_hud_resources.py
|
|
@@ -0,0 +1,88 @@
|
|
+"""Contratos estaticos del HUD y su parche; no sustituyen la ejecucion en Godot."""
|
|
+from pathlib import Path
|
|
+import math
|
|
+import re
|
|
+import unittest
|
|
+import xml.etree.ElementTree as ET
|
|
+
|
|
+ROOT = Path(__file__).resolve().parents[1]
|
|
+SCENES = ("ui/hud/player_health_hud.tscn", "ui/hud/special_charge_hud.tscn")
|
|
+
|
|
+
|
|
+class ThrashHUDResourceTests(unittest.TestCase):
|
|
+ def test_shared_resources_exist_and_load_steps_match(self):
|
|
+ for relative in (*SCENES, "ui/hud/thrash_hud_theme.tres"):
|
|
+ with self.subTest(resource=relative):
|
|
+ text = (ROOT / relative).read_text(encoding="utf-8")
|
|
+ for path in re.findall(r'path="res://([^"]+)"', text):
|
|
+ self.assertTrue((ROOT / path).is_file(), path)
|
|
+ steps = int(re.search(r"load_steps=(\d+)", text).group(1))
|
|
+ self.assertEqual(steps, 1 + len(re.findall(r"^\[(?:ext|sub)_resource ", text, re.M)))
|
|
+
|
|
+ def test_hud_controls_do_not_capture_mouse_or_touch(self):
|
|
+ for relative in SCENES:
|
|
+ for block in re.split(r"(?=^\[node )", (ROOT / relative).read_text(), flags=re.M):
|
|
+ if re.match(r'\[node .*type="(?:Control|Label|TextureRect|ProgressBar)"', block):
|
|
+ self.assertIn("mouse_filter = 2", block, (relative, block.splitlines()[0]))
|
|
+
|
|
+ def test_visual_only_script_is_the_shared_meter(self):
|
|
+ script = (ROOT / "ui/hud/thrash_meter.gd").read_text()
|
|
+ self.assertTrue(script.startswith("@tool\nclass_name ThrashMeter\nextends ProgressBar\n"))
|
|
+ self.assertIn("Engine.is_editor_hint()", script)
|
|
+ self.assertIn("@export var animations_enabled: bool = true", script)
|
|
+ self.assertNotIn("take_damage(", script)
|
|
+ self.assertNotIn("Input.", script)
|
|
+ for relative in SCENES:
|
|
+ scene = (ROOT / relative).read_text()
|
|
+ self.assertIn('path="res://ui/hud/thrash_meter.gd"', scene)
|
|
+ self.assertIn('path="res://ui/hud/thrash_hud_theme.tres"', scene)
|
|
+
|
|
+ def test_svg_art_is_self_contained_and_has_no_embedded_fonts(self):
|
|
+ for asset in (ROOT / "assets/ui/hud").glob("*.svg"):
|
|
+ with self.subTest(asset=asset.name):
|
|
+ root = ET.parse(asset).getroot()
|
|
+ self.assertGreater(int(root.attrib["width"]), 0)
|
|
+ self.assertGreater(int(root.attrib["height"]), 0)
|
|
+ for node in root.iter():
|
|
+ self.assertNotIn(node.tag.rsplit("}", 1)[-1], {"image", "text", "script", "foreignObject"})
|
|
+ for key in node.attrib:
|
|
+ self.assertFalse(key.endswith("href"))
|
|
+
|
|
+ def test_bar_and_readout_paths_are_preserved(self):
|
|
+ for relative, name in zip(SCENES, ("Health", "Special")):
|
|
+ text = (ROOT / relative).read_text()
|
|
+ self.assertIn(f'[node name="{name}Bar" type="ProgressBar" parent="HUD"]', text)
|
|
+ self.assertIn(f'[node name="{name}Label" type="Label" parent="HUD/{name}Bar"]', text)
|
|
+ theme = (ROOT / "ui/hud/thrash_hud_theme.tres").read_text()
|
|
+ self.assertIn('path="res://assets/fonts/PixelOperator8.ttf"', theme)
|
|
+ self.assertIn('ProgressBar/styles/background = SubResource("EmptyBar")', theme)
|
|
+ self.assertIn('ProgressBar/styles/fill = SubResource("EmptyBar")', theme)
|
|
+
|
|
+ def test_charge_defaults_and_economy(self):
|
|
+ script = (ROOT / "player/player.gd").read_text()
|
|
+ values = {}
|
|
+ for key in ("special_max_charge", "special_min_use_charge", "special_charge_per_kill"):
|
|
+ values[key] = int(re.search(rf"var {key}: int = (\d+)", script).group(1))
|
|
+ self.assertEqual(values, {"special_max_charge": 100, "special_min_use_charge": 25, "special_charge_per_kill": 10})
|
|
+ self.assertEqual(math.ceil(values["special_max_charge"] / values["special_charge_per_kill"]), 10)
|
|
+ self.assertEqual(math.ceil(values["special_min_use_charge"] / values["special_charge_per_kill"]), 3)
|
|
+ self.assertIn("@export var special_kills_grant_charge: bool = false", script)
|
|
+
|
|
+ def test_special_reward_context_does_not_gate_all_deaths_during_solo(self):
|
|
+ script = (ROOT / "player/player.gd").read_text()
|
|
+ damage_call = '\t\t_applying_special_damage = true\n\t\tenemy.call("take_damage", damage, global_position)\n\t\t_applying_special_damage = false'
|
|
+ self.assertIn(damage_call, script)
|
|
+ callback = script.split("func _on_enemy_died(", 1)[1].split("\nfunc ", 1)[0]
|
|
+ self.assertIn("_applying_special_damage and not special_kills_grant_charge", callback)
|
|
+ self.assertNotIn("_special_active", callback)
|
|
+
|
|
+ def test_meter_protects_zero_capacity_and_special_has_no_damage_trail(self):
|
|
+ meter = (ROOT / "ui/hud/thrash_meter.gd").read_text()
|
|
+ special = (ROOT / "ui/hud/special_charge_hud.gd").read_text()
|
|
+ self.assertIn("max_value = maxf(capacity, 1.0)", meter)
|
|
+ self.assertIn("float(amount) / float(maxi(capacity, 1))", special)
|
|
+ self.assertIn('show_damage_trail = false', (ROOT / SCENES[1]).read_text())
|
|
+
|
|
+
|
|
+if __name__ == "__main__":
|
|
+ unittest.main()
|
|
diff --git a/tests/test_thrash_hud_runtime.gd b/tests/test_thrash_hud_runtime.gd
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..befae76a68351f3c2ad22e338f19511a31b98cfd
|
|
--- /dev/null
|
|
+++ b/tests/test_thrash_hud_runtime.gd
|
|
@@ -0,0 +1,140 @@
|
|
+extends SceneTree
|
|
+
|
|
+## Ejecutar despues de importar el proyecto:
|
|
+## godot --headless --path . --script res://tests/test_thrash_hud_runtime.gd
|
|
+## Verifica valores reales, animacion, umbrales y bajas causadas por el especial.
|
|
+## La composicion visual y el editor requieren ademas una revision interactiva.
|
|
+
|
|
+var _failures: int = 0
|
|
+
|
|
+
|
|
+func _initialize() -> void:
|
|
+ call_deferred("_run")
|
|
+
|
|
+
|
|
+func _run() -> void:
|
|
+ root.size = Vector2i(1152, 648)
|
|
+ var arena := Node2D.new()
|
|
+ var player: CharacterBody2D = load("res://player/player.tscn").instantiate() as CharacterBody2D
|
|
+ var enemy: CharacterBody2D = load("res://enemies/walker/walker.tscn").instantiate() as CharacterBody2D
|
|
+ player.position = Vector2(200, 200)
|
|
+ enemy.position = Vector2(250, 200)
|
|
+ enemy.set("drops_handled_by_level", true)
|
|
+ enemy.set("respawn_delay", 0.0)
|
|
+ # El enemigo entra primero: Player conecta los miembros actuales de su grupo en _ready.
|
|
+ arena.add_child(enemy)
|
|
+ arena.add_child(player)
|
|
+ root.add_child(arena)
|
|
+ current_scene = arena
|
|
+ player.set_physics_process(false)
|
|
+ enemy.set_physics_process(false)
|
|
+ var camera: Camera2D = player.get_node("Camera2D") as Camera2D
|
|
+ camera.force_update_scroll()
|
|
+ await process_frame
|
|
+
|
|
+ var health_hud: CanvasLayer = player.get_node("PlayerHealthHUD") as CanvasLayer
|
|
+ var special_hud: CanvasLayer = player.get_node("SpecialChargeHUD") as CanvasLayer
|
|
+ var health_bar: ThrashMeter = health_hud.get_node("HUD/HealthBar") as ThrashMeter
|
|
+ var special_bar: ThrashMeter = special_hud.get_node("HUD/SpecialBar") as ThrashMeter
|
|
+ var health_label: Label = health_bar.get_node("HealthLabel") as Label
|
|
+ var special_label: Label = special_bar.get_node("SpecialLabel") as Label
|
|
+ var warning_label: Label = health_hud.get_node("HUD/WarningLabel") as Label
|
|
+ var status_label: Label = special_hud.get_node("HUD/StatusLabel") as Label
|
|
+ _check(health_hud.visible and special_hud.visible, "Los dos HUD deben verse al jugar")
|
|
+ _check(health_label.text == "50 / 50", "La primera lectura de vida debe llegar sin animacion")
|
|
+ _check(is_equal_approx(health_bar.value, 50.0), "Vida inicial incorrecta")
|
|
+ _check(special_label.text == "0%", "El especial debe empezar vacio")
|
|
+
|
|
+ player.emit_signal("health_changed", 10, 50)
|
|
+ _check(health_label.text == "10 / 50", "El numero debe cambiar en el mismo evento")
|
|
+ _check(health_bar.highlighted and warning_label.visible, "Falta el aviso de poca vida")
|
|
+ _check(is_equal_approx(float(health_bar.get("_display_ratio")), 0.2), "La perdida de vida no debe retrasarse")
|
|
+ _check(is_equal_approx(float(health_bar.get("_trail_ratio")), 1.0), "La estela debe recordar la vida perdida")
|
|
+ health_bar.call("_process", 1.0)
|
|
+ _check(is_equal_approx(float(health_bar.get("_trail_ratio")), 0.2), "La estela debe desaparecer")
|
|
+ player.emit_signal("health_changed", 40, 50)
|
|
+ _check(not warning_label.visible and not health_bar.highlighted, "Curarse debe quitar el aviso")
|
|
+ health_bar.animations_enabled = false
|
|
+ player.emit_signal("health_changed", 25, 50)
|
|
+ _check(not health_bar.is_processing(), "Sin animacion no debe haber procesamiento visual continuo")
|
|
+ _check(is_equal_approx(float(health_bar.get("_display_ratio")), 0.5), "El modo estatico debe actualizarse al instante")
|
|
+ player.emit_signal("health_changed", 0, 0)
|
|
+ _check(health_label.text == "0 / 0" and is_zero_approx(health_bar.value), "Capacidad nula de vida")
|
|
+ player.emit_signal("health_changed", 50, 50)
|
|
+
|
|
+ # Diez notificaciones de baja ordinaria; el test de combate ya verifica died una sola vez por muerte.
|
|
+ for kills: int in range(1, 12):
|
|
+ player.call("_on_enemy_died", enemy)
|
|
+ _check(int(player.get("special_charge")) == mini(kills * 10, 100), "Carga o saturacion incorrecta")
|
|
+ if kills == 1:
|
|
+ _check(is_zero_approx(float(special_bar.get("_display_ratio"))), "La ganancia debe iniciar una subida, no saltar")
|
|
+ special_bar.call("_process", 0.1)
|
|
+ _check(is_equal_approx(float(special_bar.get("_display_ratio")), 0.05), "10 puntos deben interpolarse en 0.2 segundos")
|
|
+ if kills == 2:
|
|
+ _check(status_label.text == "CARGANDO" and not special_bar.highlighted, "20 puntos no bastan")
|
|
+ player.call("_start_special_attack")
|
|
+ _check(not bool(player.get("_special_active")), "No debe iniciarse el solo con 20 puntos")
|
|
+ _check(int(player.get("special_charge")) == 20, "Un intento invalido no consume carga")
|
|
+ if kills == 3:
|
|
+ _check(status_label.text == "LISTO" and special_bar.highlighted, "30 puntos deben permitir el solo")
|
|
+ _check(status_label.text == "AL 11" and special_label.text == "100%", "Falta el estado de carga completa")
|
|
+ player.call("_start_special_attack")
|
|
+ _check(bool(player.get("_special_active")), "La carga completa debe activar el solo")
|
|
+ _check(int(player.get("special_charge")) == 0 and special_label.text == "0%", "El solo debe consumir la carga")
|
|
+ _check(is_zero_approx(float(special_bar.get("_display_ratio"))), "La barra debe vaciarse sin retraso")
|
|
+
|
|
+ # Una baja ajena al dano del solo sigue concediendo carga aunque la animacion este activa.
|
|
+ player.call("_on_enemy_died", enemy)
|
|
+ _check(int(player.get("special_charge")) == 10, "No se deben filtrar otras bajas durante el solo")
|
|
+ enemy.set("current_health", 1)
|
|
+ player.call("_apply_special_attack", 100, 0)
|
|
+ _check(bool(enemy.get("is_dead")), "El pulso de prueba debe matar al enemigo visible")
|
|
+ _check(int(player.get("special_charge")) == 10, "El solo no debe recargarse con su propia baja")
|
|
+ _check(not bool(player.get("_applying_special_damage")), "El contexto de dano debe restaurarse")
|
|
+
|
|
+ # Enemigo nuevo para comprobar la opcion de restaurar la regla anterior.
|
|
+ var second_enemy: CharacterBody2D = load("res://enemies/walker/walker.tscn").instantiate() as CharacterBody2D
|
|
+ second_enemy.position = player.position + Vector2(50, 0)
|
|
+ second_enemy.set("drops_handled_by_level", true)
|
|
+ second_enemy.set("respawn_delay", 0.0)
|
|
+ arena.add_child(second_enemy)
|
|
+ second_enemy.set_physics_process(false)
|
|
+ second_enemy.set("current_health", 1)
|
|
+ second_enemy.connect(&"died", Callable(player, "_on_enemy_died").bind(second_enemy))
|
|
+ player.set("special_kills_grant_charge", true)
|
|
+ player.call("_apply_special_attack", 100, 0)
|
|
+ _check(bool(second_enemy.get("is_dead")), "El segundo pulso de prueba debe acertar")
|
|
+ _check(int(player.get("special_charge")) == 20, "La opcion de recarga propia debe funcionar")
|
|
+ _check(not bool(player.get("_applying_special_damage")), "El contexto no debe quedar activado")
|
|
+
|
|
+ # La UI respeta capacidad y minimo configurados, en vez de asumir siempre 100 y 25.
|
|
+ player.set("special_max_charge", 50)
|
|
+ player.set("special_min_use_charge", 25)
|
|
+ player.emit_signal("special_charge_changed", 25, 50)
|
|
+ _check(special_label.text == "50%", "25 de 50 debe indicar 50%")
|
|
+ _check(is_equal_approx(special_bar.activation_ratio, 0.5), "La marca debe seguir el umbral real")
|
|
+ player.set("special_min_use_charge", 60)
|
|
+ player.emit_signal("special_charge_changed", 50, 50)
|
|
+ _check(status_label.text == "DESACTIVADO" and not special_bar.highlighted, "Un umbral imposible no debe aparecer listo")
|
|
+ player.emit_signal("special_charge_changed", 0, 0)
|
|
+ _check(special_label.text == "0%" and is_zero_approx(special_bar.value), "Capacidad cero de especial")
|
|
+
|
|
+ # Los objetos conservan su potencia; el cambio de balance solo afecta a las bajas.
|
|
+ player.set("special_max_charge", 100)
|
|
+ player.set("special_min_use_charge", 25)
|
|
+ player.set("special_charge", 0)
|
|
+ var tape: PickupData = load("res://pickups/data/casete_demo.tres") as PickupData
|
|
+ _check(bool(player.call("collect_pickup", tape)), "El casete debe seguir recargando")
|
|
+ _check(int(player.get("special_charge")) == 25, "No debe alterarse la recompensa del casete")
|
|
+
|
|
+ arena.queue_free()
|
|
+ await process_frame
|
|
+ if _failures == 0:
|
|
+ print("OK THRASH HUD: vida, estela, estados, umbrales, capacidad cero y economia del solo")
|
|
+ quit(0 if _failures == 0 else 1)
|
|
+
|
|
+
|
|
+func _check(condition: bool, message: String) -> void:
|
|
+ if not condition:
|
|
+ _failures += 1
|
|
+ push_error(message)
|
|
diff --git a/ui/editor_ui_visibility.gd b/ui/editor_ui_visibility.gd
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c3541f7716ba305a3c9ce0966667699d116acffc
|
|
--- /dev/null
|
|
+++ b/ui/editor_ui_visibility.gd
|
|
@@ -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()
|
|
diff --git a/ui/hud/player_health_hud.gd b/ui/hud/player_health_hud.gd
|
|
index bbde237160541c4b1529a31d61eff9f1c3abf820..3ec8764218192d688a53099c57338674cd2078d2 100644
|
|
--- a/ui/hud/player_health_hud.gd
|
|
+++ b/ui/hud/player_health_hud.gd
|
|
@@ -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"
|
|
diff --git a/ui/hud/player_health_hud.tscn b/ui/hud/player_health_hud.tscn
|
|
index 486487c66b42208cbd5ea840c9f43bb27454826c..dc78cc0d6b27ba2eb45cf8d3fae16f00def51435 100644
|
|
--- a/ui/hud/player_health_hud.tscn
|
|
+++ b/ui/hud/player_health_hud.tscn
|
|
@@ -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
|
|
+texture = ExtResource("plate")
|
|
+expand_mode = 1
|
|
+
|
|
+[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
|
|
+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="HealthBar" type="ProgressBar" parent="HUD"]
|
|
+layout_mode = 0
|
|
+offset_left = 84.0
|
|
+offset_top = 48.0
|
|
+offset_right = 346.0
|
|
+offset_bottom = 68.0
|
|
mouse_filter = 2
|
|
-theme_override_styles/background = SubResource("HealthBackground")
|
|
-theme_override_styles/fill = SubResource("HealthFill")
|
|
-max_value = 5.0
|
|
-value = 5.0
|
|
+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 = 1
|
|
-anchors_preset = 15
|
|
-anchor_right = 1.0
|
|
-anchor_bottom = 1.0
|
|
-grow_horizontal = 2
|
|
-grow_vertical = 2
|
|
+layout_mode = 0
|
|
+offset_left = 132.0
|
|
+offset_top = -23.0
|
|
+offset_right = 262.0
|
|
+offset_bottom = -3.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"
|
|
-horizontal_alignment = 1
|
|
+text = "50 / 50"
|
|
+horizontal_alignment = 2
|
|
vertical_alignment = 1
|
|
|
|
[node name="EffectsLabel" type="Label" parent="HUD"]
|
|
+visible = false
|
|
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 = 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
|
|
diff --git a/ui/hud/special_charge_hud.gd b/ui/hud/special_charge_hud.gd
|
|
index 91a471616ae36826bea1918efd932345382cd397..b529bb0ea4ed88c8dfc715c0b8bf5ebc965e743c 100644
|
|
--- a/ui/hud/special_charge_hud.gd
|
|
+++ b/ui/hud/special_charge_hud.gd
|
|
@@ -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"))
|
|
diff --git a/ui/hud/special_charge_hud.tscn b/ui/hud/special_charge_hud.tscn
|
|
index 4ed6130a6813d3f031f429e1914615691da6ef95..bde404c1acfdc5d75b7861e1214cc21df3d836cd 100644
|
|
--- a/ui/hud/special_charge_hud.tscn
|
|
+++ b/ui/hud/special_charge_hud.tscn
|
|
@@ -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="SpecialBar" type="ProgressBar" parent="HUD"]
|
|
+[node name="Frame" type="TextureRect" parent="HUD"]
|
|
+layout_mode = 0
|
|
offset_left = 18.0
|
|
-offset_top = 74.0
|
|
-offset_right = 278.0
|
|
-offset_bottom = 94.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"]
|
|
+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"
|
|
diff --git a/ui/hud/thrash_hud_theme.tres b/ui/hud/thrash_hud_theme.tres
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..bdf95b424b1f4688771e158e357e71d05ee02671
|
|
--- /dev/null
|
|
+++ b/ui/hud/thrash_hud_theme.tres
|
|
@@ -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")
|
|
diff --git a/ui/hud/thrash_meter.gd b/ui/hud/thrash_meter.gd
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..882521fad4d724d844e9f37ee1ad74e57f8b81da
|
|
--- /dev/null
|
|
+++ b/ui/hud/thrash_meter.gd
|
|
@@ -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)
|
|
diff --git a/ui/mobile_controls/mobile_controls.tscn b/ui/mobile_controls/mobile_controls.tscn
|
|
index 9452f271cec92850116e5effd9aa5e3ae70522c5..db4bba979c6fe97c6e13040741ed6948e8697dc1 100644
|
|
--- a/ui/mobile_controls/mobile_controls.tscn
|
|
+++ b/ui/mobile_controls/mobile_controls.tscn
|
|
@@ -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
|