diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-17 19:41:46 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-17 19:41:46 +0100 |
commit | f75ee64e21f67b4f27404147aedaa63750058d5a (patch) | |
tree | 8e35f5b0ca986169e46ef1f90c3fdd951a9af113 /scripts/spawner.gd | |
parent | a7bda4264b45c0c64fd81ac91b4f1fbbc539e314 (diff) |
wave
Diffstat (limited to 'scripts/spawner.gd')
-rw-r--r-- | scripts/spawner.gd | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/spawner.gd b/scripts/spawner.gd new file mode 100644 index 0000000..9866168 --- /dev/null +++ b/scripts/spawner.gd @@ -0,0 +1,24 @@ +extends Timer + +var enemy_holder : Node +var queue : Array + +func fetch (): + var root = get_tree().root.get_node("world") + enemy_holder = root.get_node("enemies") + +func next (): + if queue.size() == 0: return null + var n = queue[0] + queue.remove(0) + return n + +func _on_timer_batch_timeout(): + # fetch called by wave + var n = next() + if n == null: + queue_free() + return + + enemy_holder.spawn(n.enemy) + start(n.cooldown) |