extends Node2D

var boxTotal = 4
var timer:= Timer.new()
var countdown = 10

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	add_child(timer)
	timer.wait_time = 1
	timer.one_shot = false
	timer.connect("timeout", secondCounter)
	# timer.start()

func secondCounter():
	countdown -=1
	if countdown <=0:
		print("YOU LOSE")
		get_tree().reload_current_scene()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass


func _on_trigger(effect: Variant, body) -> void:
	print("Game Controller sees an alert")
	if body is RigidBody2D:
		print("I see a crate")
		body.queue_free()
		boxTotal -=1
		if boxTotal <=0:
			print("YOU WON!!")
			get_tree().reload_current_scene()