mejoras en jugabilidad
This commit is contained in:
1 parent
d983bc2e69
commit
ec7e35ddf6
40 files changed
+856
-538
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user