extends Control

@onready var time_label = get_node("%TimeSpent")
@onready var drones_label = get_node("%DronesUsed")
@onready var points_label = get_node("%TotalPoints")

@onready var main_menu_button = get_node("%MainMenu")

func _ready():
	visible = false

	main_menu_button.connect("pressed", Callable(self, "on_main_menu_pressed"))

func _process(_delta):
	if GameState.level_complete == true:
		update_points()
		visible = true

func update_points():
	time_label.text = "Time Spent: " + Str.seconds_to_hms(GameState.level_timer)
	drones_label.text = "Drones Used: " + str(GameState.drones_used)
	points_label.text = "Total Points: " + Str.format_number(GameState.level_points)

func on_main_menu_pressed():
	GameState.reset()
	SceneMgr.load_scene("MAINMENU")