Rooms can now be locked down and open when all enemies are killed
This commit is contained in:
@@ -65,3 +65,9 @@ func _physics_process(delta):
|
||||
ray.get_collider().breaking(current_velocity)
|
||||
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
if !body.is_in_group("player"):
|
||||
await get_tree().create_timer(.1).timeout
|
||||
mesh.visible = false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
|
||||
signal player_entered_room()
|
||||
signal player_left_room()
|
||||
signal room_entered()
|
||||
signal room_exited()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -13,8 +13,8 @@ func _process(delta: float) -> void:
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if body.is_in_group("player"):
|
||||
emit_signal("player_entered_room")
|
||||
emit_signal("room_entered")
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
if body.is_in_group("player"):
|
||||
emit_signal("player_left_room")
|
||||
emit_signal("room_exited")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
extends Node
|
||||
|
||||
@export var room_lockdown : bool = false
|
||||
|
||||
var enemies = []
|
||||
var doors = []
|
||||
var room_checks = []
|
||||
@@ -16,7 +18,10 @@ func _ready():
|
||||
doors.append(i)
|
||||
if i.is_in_group("room_check"):
|
||||
room_checks.append(i)
|
||||
i.room_entered.connect(room_entered)
|
||||
i.room_exited.connect(room_exited)
|
||||
|
||||
print("Doors: " + str(doors))
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
@@ -53,5 +58,18 @@ func _process(delta):
|
||||
i.last_enemy = true
|
||||
|
||||
func last_enemy_dead():
|
||||
if room_lockdown:
|
||||
room_lockdown = false
|
||||
|
||||
for i in doors:
|
||||
i.open()
|
||||
if !i.door_open:
|
||||
i.open()
|
||||
|
||||
func room_entered():
|
||||
if room_lockdown:
|
||||
for i in doors:
|
||||
if i.door_open:
|
||||
i.close()
|
||||
|
||||
func room_exited():
|
||||
print("ELVIS HAS LEFT THE BUILDING")
|
||||
|
||||
Reference in New Issue
Block a user