64 lines
1.5 KiB
GDScript
64 lines
1.5 KiB
GDScript
extends Control
|
|
|
|
var upgrade_node: Node
|
|
var available_money: int = 0
|
|
var special_currency: int = 0
|
|
|
|
|
|
signal shop_exit
|
|
|
|
func _process(delta: float) -> void:
|
|
$Money.text = str(available_money)
|
|
$SpecialMoney.text = str(special_currency)
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func populate() -> void:
|
|
$TuxUpgrades.clear()
|
|
for upgrade in upgrade_node.get_children():
|
|
var index = $TuxUpgrades.add_item(upgrade.upgrade_description + " Cost: " + str(upgrade.cost), upgrade.icon)
|
|
$TuxUpgrades.set_item_metadata(index, upgrade)
|
|
if upgrade.enabled:
|
|
$TuxUpgrades.set_item_disabled(index, true)
|
|
|
|
|
|
|
|
|
|
func _on_tux_mouse_entered() -> void:
|
|
$Tux.modulate = Color(0.5, 0.5, 0.6)
|
|
|
|
|
|
func _on_tux_mouse_exited() -> void:
|
|
$Tux.modulate = Color(1, 1, 1)
|
|
|
|
|
|
func _on_tux_upgrades_item_clicked(index: int, at_position: Vector2, mouse_button_index: int) -> void:
|
|
var upgrade = $TuxUpgrades.get_item_metadata(index)
|
|
if upgrade.cost <= available_money:
|
|
upgrade.enabled = true;
|
|
available_money -= upgrade.cost
|
|
populate()
|
|
else:
|
|
$Error.text = "No tens prou Diners!!!!"
|
|
|
|
|
|
func _on_continue_pressed() -> void:
|
|
$Tux.visible = true
|
|
$Xenia.visible = true
|
|
$TuxUpgrades.visible = false
|
|
shop_exit.emit()
|
|
|
|
|
|
func _on_xenia_mouse_entered() -> void:
|
|
$Xenia.modulate = Color(0.5, 0.5, 0.6)
|
|
|
|
|
|
func _on_xenia_mouse_exited() -> void:
|
|
$Xenia.modulate = Color(1, 1, 1)
|
|
|
|
|
|
func _on_tux_pressed() -> void:
|
|
$Tux.visible = false
|
|
$Xenia.visible = false
|
|
$TuxUpgrades.visible = true
|