Prueba de boss final
This commit is contained in:
1 parent
ac1d386143
commit
f414d43a37
6 files changed
+577
No files matched your search
@@ -0,0 +1,56 @@
|
||||
extends LevelRoot
|
||||
## Pasillo, puerta de exterminio y descenso a la camara final.
|
||||
const LOCKED_TEXT: String = "has de derrotar a todos los mal nacidos para poder atravesar esta puerta!"
|
||||
var remaining: int = 0
|
||||
var _gate_open: bool = false
|
||||
var _boss_defeated: bool = false
|
||||
|
||||
@onready var gate: StaticBody2D = $Gate
|
||||
@onready var gate_shape: CollisionShape2D = $Gate/CollisionShape2D
|
||||
@onready var gate_visual: Polygon2D = $Gate/Visual
|
||||
@onready var notice: Label = $GateMessage/Text
|
||||
@onready var boss: Node2D = $Boss
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
for enemy: Node in $Enemies.get_children():
|
||||
if enemy.has_signal("died"):
|
||||
remaining += 1
|
||||
enemy.connect("died", _on_enemy_died)
|
||||
boss.connect("died", _on_boss_died)
|
||||
$GateSensor.body_entered.connect(_on_gate_approach)
|
||||
$GateSensor.body_exited.connect(_on_gate_depart)
|
||||
_update_gate()
|
||||
|
||||
func _on_enemy_died() -> void:
|
||||
remaining = maxi(0, remaining - 1)
|
||||
_update_gate()
|
||||
|
||||
func _update_gate() -> void:
|
||||
_gate_open = remaining == 0
|
||||
gate_shape.set_deferred("disabled", _gate_open)
|
||||
gate_visual.visible = not _gate_open
|
||||
if _gate_open:
|
||||
notice.text = "TODOS DERROTADOS. EL SELLO SE HA ROTO."
|
||||
else:
|
||||
notice.text = LOCKED_TEXT
|
||||
|
||||
func _on_gate_approach(body: Node2D) -> void:
|
||||
if body.is_in_group("player"):
|
||||
$GateMessage.visible = true
|
||||
|
||||
func _on_gate_depart(body: Node2D) -> void:
|
||||
if body.is_in_group("player"):
|
||||
$GateMessage.visible = false
|
||||
|
||||
func _on_boss_died() -> void:
|
||||
if _boss_defeated:
|
||||
return
|
||||
_boss_defeated = true
|
||||
progress_notice.emit("LA MUERTE ESPECTRAL HA CAIDO")
|
||||
get_tree().create_timer(1.5).timeout.connect(_finish_after_boss)
|
||||
|
||||
func _finish_after_boss() -> void:
|
||||
if not is_inside_tree():
|
||||
return
|
||||
complete_level()
|
||||
Reference in new issue
Block a user