extends Node2D
class_name GameOver

func _ready() -> void:
	$CanvasLayer/VBoxContainer/NewGameBtn.grab_focus()
	var run_data = GameState.get_run_data()
	var score = run_data.score
	$CanvasLayer/Scores/Coins/amount.text = str(run_data.coins)
	$CanvasLayer/Scores/Lifes/amount.text = str(run_data.deaths)
	$CanvasLayer/Scores/Orbs/amount.text = str(run_data.orbs)
	var coin_score = run_data.coins * 10
	var live_score = run_data.deaths * -2
	var orbs_score = run_data.orbs * 100

	$CanvasLayer/Scores/Coins/score.text = str(coin_score)
	$CanvasLayer/Scores/Lifes/score.text = str(live_score)
	$CanvasLayer/Scores/Orbs/score.text = str(orbs_score)

	$CanvasLayer/Scores/Totals/total.text = str(score)

func _on_ExitToMainMenuBtn_pressed() -> void:
	$AnimationPlayer.play_backwards("fade")
	yield($AnimationPlayer, "animation_finished");
	AudioManager.play_music(AudioManager.Music.Intro)
	GameState.go_to_main_menu()
	queue_free()


func _on_NewGameBtn_pressed() -> void:
	$AnimationPlayer.play_backwards("fade")
	yield($AnimationPlayer, "animation_finished");
	GameState.start_new_game()
	queue_free()
	pass # Replace with function body.
