mejoras en jugabilidad

This commit is contained in:
Diego De la Viuda Llorente committed 2026-11-11 18:14:14 +01:00
1 parent d983bc2e69
commit ec7e35ddf6
40 files changed
+856 -538

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
@tool
extends Node
## Componente colocable: escucha la muerte de un jefe y finaliza el LevelRoot.
## El jefe solo necesita emitir died; no se modifica su script al disenar niveles.
@export var boss_path: NodePath:
set(value):
boss_path = value
update_configuration_warnings()
@export_range(0.0, 10.0, 0.1) var completion_delay: float = 1.5
@export var victory_message: String = ""
var _triggered: bool = false
func _ready() -> void:
if Engine.is_editor_hint():
update_configuration_warnings()
return
var boss: Node = get_node_or_null(boss_path) if not boss_path.is_empty() else null
if boss == null or not boss.has_signal(&"died"):
push_error("BossVictory: Boss Path debe apuntar a un nodo que emita died.")
return
boss.connect(&"died", _on_boss_died)
func _on_boss_died() -> void:
if _triggered:
return
_triggered = true
var level: LevelRoot = LevelRoot.find_for(self)
if level != null and not victory_message.is_empty():
level.progress_notice.emit(victory_message)
get_tree().create_timer(completion_delay).timeout.connect(_finish)
func _finish() -> void:
if not is_inside_tree():
return
var level: LevelRoot = LevelRoot.find_for(self)
if level != null:
level.complete_level()
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if boss_path.is_empty():
warnings.append("Asigna Boss Path al jefe que debe morir para completar el nivel.")
elif is_inside_tree():
var boss: Node = get_node_or_null(boss_path) if not boss_path.is_empty() else null
if boss == null or not boss.has_signal(&"died"):
warnings.append("Boss Path debe apuntar a un nodo con senal died.")
return warnings
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://world/triggers/boss_victory.gd" id="logic"]
[node name="BossVictory" type="Node"]
script = ExtResource("logic")
+88
View File
@@ -0,0 +1,88 @@
@tool
extends StaticBody2D
class_name KillGate
## Puerta reutilizable: configura el contenedor de enemigos que la desbloquea.
## Solo esos hijos directos con senal died cuentan; admite varios portones por nivel.
@export var enemies_root_path: NodePath:
set(value):
enemies_root_path = value
update_configuration_warnings()
@export_multiline var locked_message: String = "has de derrotar a todos los mal nacidos para poder atravesar esta puerta!"
@export_multiline var unlocked_message: String = "TODOS DERROTADOS. EL SELLO SE HA ROTO."
var remaining: int = 0
var _open: bool = false
@onready var gate_shape: CollisionShape2D = $CollisionShape2D
@onready var gate_visual: OssuaryGateVisual = $Visual
@onready var notice: Label = $Message/Text
func _ready() -> void:
if Engine.is_editor_hint():
update_configuration_warnings()
return
var enemies_root: Node = get_node_or_null(enemies_root_path) if not enemies_root_path.is_empty() else null
if enemies_root == null:
push_error("KillGate: selecciona Enemies Root Path en el Inspector.")
return
for enemy: Node in enemies_root.get_children():
if not enemy.has_signal(&"died"):
continue
if bool(enemy.get("is_dead")):
continue
remaining += 1
enemy.connect(&"died", _on_enemy_died)
gate_visual.fully_open.connect(_on_gate_fully_opened)
$Sensor.body_entered.connect(_on_gate_approach)
$Sensor.body_exited.connect(_on_gate_depart)
$Message.visible = false
_update_gate()
func _on_enemy_died() -> void:
remaining = maxi(0, remaining - 1)
_update_gate()
func _update_gate() -> void:
_open = remaining == 0
gate_visual.set_unlocked(_open)
if not _open:
gate_shape.set_deferred("disabled", false)
notice.text = unlocked_message if _open else locked_message
func _on_gate_fully_opened() -> void:
# Conserva la colision hasta que la apertura visual haya terminado.
gate_shape.set_deferred("disabled", true)
func _on_gate_approach(body: Node2D) -> void:
if body.is_in_group(&"player"):
$Message.visible = true
func _on_gate_depart(body: Node2D) -> void:
if body.is_in_group(&"player"):
$Message.visible = false
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if enemies_root_path.is_empty():
warnings.append("Asigna Enemies Root Path al contenedor de los enemigos requeridos.")
elif is_inside_tree():
var root: Node = get_node_or_null(enemies_root_path)
if root == null:
warnings.append("Enemies Root Path no apunta a un nodo existente.")
else:
var found: bool = false
for child: Node in root.get_children():
if child.has_signal(&"died"):
found = true
break
if not found:
warnings.append("El contenedor no tiene hijos directos con senal died; la puerta se abrira sola.")
return warnings
+46
View File
@@ -0,0 +1,46 @@
[gd_scene load_steps=5 format=3]
[ext_resource type="Script" path="res://world/triggers/kill_gate.gd" id="gate"]
[ext_resource type="Script" path="res://world/triggers/ossuary_gate_visual.gd" id="visual"]
[sub_resource type="RectangleShape2D" id="gate_collision"]
size = Vector2(44, 220)
[sub_resource type="RectangleShape2D" id="gate_sensor"]
size = Vector2(320, 260)
[node name="KillGate" type="StaticBody2D"]
collision_layer = 1
collision_mask = 0
script = ExtResource("gate")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("gate_collision")
[node name="Visual" type="Node2D" parent="."]
script = ExtResource("visual")
[node name="Sensor" type="Area2D" parent="."]
position = Vector2(-40, 0)
collision_layer = 0
collision_mask = 2
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sensor"]
shape = SubResource("gate_sensor")
[node name="Message" type="CanvasLayer" parent="."]
visible = false
layer = 4
[node name="Text" type="Label" parent="Message"]
anchors_preset = 10
anchor_right = 1.0
offset_top = 110.0
offset_bottom = 170.0
horizontal_alignment = 1
vertical_alignment = 1
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(1, 0.83, 0.62, 1)
autowrap_mode = 3
text = "has de derrotar a todos los mal nacidos para poder atravesar esta puerta!"
+5
View File
@@ -1,3 +1,4 @@
@tool
extends Node2D
class_name OssuaryGateVisual
## Porton de calaveras provisional: hojas de hierro, cadenas, sello y apertura
@@ -27,6 +28,10 @@ func set_unlocked(value: bool) -> void:
func _process(delta: float) -> void:
if Engine.is_editor_hint():
# Preview fija en el editor; animacion real solo durante la partida.
queue_redraw()
return
_elapsed += delta
_progress = move_toward(_progress, 1.0 if _unlocked else 0.0, delta / open_duration)
if _unlocked and _progress >= 1.0 and not _signalled: