extends MarginContainer

var can_purchase = true

var package_selected = false

onready var purchase_button = $Panel/MarginContainer/VBoxContainer/Purchase/Button

func _ready():
	print("doing the thing")
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	get_tree().call_group("player","cutscene_mode",true)
	get_tree().paused = true
	
func _input(event):
	if Input.is_action_just_pressed("ui_cancel"):
		get_tree().call_group("player","cutscene_mode",false)
		queue_free()


func _on_Button_pressed():
	package_selected = true
	if can_purchase:
		purchase_button.disabled = false
		


func purchase():
	purchase_button.text = "Purchasing..."
	purchase_button.disabled = true
	can_purchase = false
	var t = Timer.new()
	t.set_wait_time(1.85)
	t.set_one_shot(true)
	self.add_child(t)
	t.start()
	yield(t, "timeout")
	can_purchase = true
	purchase_button.disabled = false
	purchase_button.text = "Try again later"
