aboutsummaryrefslogtreecommitdiff
path: root/scripts/spawner.gd
blob: 986616881ac549bb962f48abdd15a92b0a2f87d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)