summaryrefslogtreecommitdiff
path: root/Scenes/Maps/Base01.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-05-06 16:30:46 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-05-06 16:30:46 +0200
commit276b7664bd4a475a3ca93a682c16b49c504c58f7 (patch)
tree6b8f8cf0e1a82496c1f539e55e26bc078300b23a /Scenes/Maps/Base01.gd
parent8c0e8b5bf73caaf2fd6f04fb97b9c13f2970c431 (diff)
update
Diffstat (limited to 'Scenes/Maps/Base01.gd')
-rw-r--r--Scenes/Maps/Base01.gd57
1 files changed, 57 insertions, 0 deletions
diff --git a/Scenes/Maps/Base01.gd b/Scenes/Maps/Base01.gd
index adeac93..83947e4 100644
--- a/Scenes/Maps/Base01.gd
+++ b/Scenes/Maps/Base01.gd
@@ -10,6 +10,32 @@ func _ready():
[],
get_node("Areas/MapArea/Transitions").get_children()
)
+
+ place_boxes(
+ get_node("Areas/MapArea2/TileMap"),
+ 40,
+ [],
+ get_node("Areas/MapArea2/Objects").get_children()
+ )
+ get_node("Areas/MapArea2").transitioned_to.connect(func():
+ handle_doors(
+ get_node("Areas/MapArea2/Objects").get_children(),
+ door_condition_enemies(Utilities.get_enemy_children(get_node("Areas/MapArea2/TileMap")))
+ )
+ )
+
+ place_boxes(
+ get_node("Areas/MapArea6/TileMap"),
+ 40,
+ [],
+ get_node("Areas/MapArea6/Objects").get_children()
+ )
+ get_node("Areas/MapArea6").transitioned_to.connect(func():
+ handle_doors(
+ get_node("Areas/MapArea6/Objects").get_children(),
+ door_condition_enemies(Utilities.get_enemy_children(get_node("Areas/MapArea6/TileMap")))
+ )
+ )
# set box to random position without polygon points
@@ -71,3 +97,34 @@ func place_boxes(
var box = BoxScene.instantiate()
box.position = tilemap.map_to_local(placeable_cells[number])
tilemap.add_child(box)
+
+
+func handle_doors(doors: Array, condition):
+ for door in doors:
+ door.enable()
+
+ if condition.check():
+ for door in doors:
+ door.disable()
+
+ condition.fulfilled.connect(func():
+ for door in doors:
+ door.disable()
+ )
+
+func door_condition_enemies(enemies: Array):
+ var condition = Utilities.Condition.new()
+ condition.function = func():
+ for enemy in enemies:
+ enemy.tree_exited.connect(func():
+ enemies.erase(enemy)
+ if enemies.is_empty():
+ condition.fulfilled.emit()
+ )
+
+ if enemies.is_empty():
+ return true
+
+ return false
+
+ return condition