extends Node

var score = 0 setget set_score
onready var scoreLabel = $Score


func set_score(value):
	score = value
	update_score(str(value))

func update_score(value):
	scoreLabel.text = "Score = " + value

func update_save_data():
	var save_data = SaveLoad.load_save_data()
	if score > save_data.hi_score:
		save_data.hi_score = score
		SaveLoad.store_save_data(save_data)

func _on_Ship_player_death():
	update_save_data()
	# Yield until the timer expires
	yield(get_tree().create_timer(1), "timeout")
	# warning-ignore:return_value_discarded
	get_tree().change_scene("res://Scenes/Stages/GameOver.tscn")
