extends Node2D

export(PackedScene) var enemyScn 
var limit = 1

func _process(delta):
	if GameManager.enemiesDestroyed >= 2:
			limit = 2
	if GameManager.enemiesDestroyed >= 4:
			limit = 3
	if GameManager.enemiesDestroyed >= 5:
			limit = 4
	if GameManager.enemiesDestroyed >= 7:
			limit = 5
	if GameManager.enemiesDestroyed >= 9:
			limit = 8

func _on_Timer_timeout():
	if get_node("/root/Level/Enemies").get_child_count() <  limit:
		var enemy = enemyScn.instance()
		enemy.position = position
		get_node("/root/Level/Enemies").add_child(enemy)
		GameManager.enemies.append(enemy)
