extends Node

signal refund
signal speed_upgrade
signal bullet_delay_upgrade
signal ship_speed_upgrade
signal add_laser
signal plasma_lasers

var bullet_delay_tier
var shooting_speed_tier
var ship_speed_tier
var double_lasers

func _ready():
	bullet_delay_tier = get_parent().bullet_delay_tier
	$ShootingSpeedUpgrade/Icon.frame = bullet_delay_tier
	ship_speed_tier = get_parent().ship_speed_tier
	$ShipSpeedUpgrade/Icon.frame = ship_speed_tier

func _process(delta):
	$ShootingSpeedUpgrade/Icon.frame = bullet_delay_tier
	$ShipSpeedUpgrade/Icon.frame = ship_speed_tier
	if (Input.is_action_pressed("ui_quit")):
		get_tree().quit()
	if Input.is_action_pressed("ui_accept"):
		_on_Button_pressed()

func _on_Button_pressed():
	get_tree().paused = false
	queue_free()

func _on_Refund_pressed():
	bullet_delay_tier = 0
	ship_speed_tier = 0
	$ShootingSpeedUpgrade/Icon.frame = 0
	$ShipSpeedUpgrade/Icon.frame = 0
	get_tree().paused = false
	emit_signal("refund")

func _on_ShootingSpeedUpgrade_pressed():
	get_tree().paused = false
	emit_signal("bullet_delay_upgrade")
	bullet_delay_tier = get_parent().bullet_delay_tier

func _on_ShipSpeedUpgrade_pressed():
	get_tree().paused = false
	emit_signal("ship_speed_upgrade")
	prints("UPGRADE SHIP SPEED SIGNAL EMITTED")
	ship_speed_tier = get_parent().ship_speed_tier
