89 lines
2.4 KiB
GDScript
89 lines
2.4 KiB
GDScript
extends Control
|
|
|
|
var upgrade_node: Node
|
|
var special_upgrade_node: Node
|
|
var available_money: int = 0
|
|
var special_currency: int = 0
|
|
|
|
signal shop_exit
|
|
|
|
func _ready() -> void:
|
|
$Tux.visible = true
|
|
$Xenia.visible = true
|
|
$TuxUpgrades.visible = false
|
|
$XeniaUpgrades.visible = false
|
|
|
|
|
|
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)
|
|
|
|
$XeniaUpgrades.clear()
|
|
for upgrade in special_upgrade_node.get_children():
|
|
var index = $XeniaUpgrades.add_item(upgrade.upgrade_description + " Cost: " + str(upgrade.cost), upgrade.icon)
|
|
$XeniaUpgrades.set_item_metadata(index, upgrade)
|
|
if upgrade.enabled:
|
|
$XeniaUpgrades.set_item_disabled(index, true)
|
|
|
|
|
|
func _on_tux_mouse_entered() -> void:
|
|
$Tux.modulate = Color(0.5, 0.5, 0.6)
|
|
func _on_xenia_mouse_entered() -> void:
|
|
$Xenia.modulate = Color(0.5, 0.5, 0.6)
|
|
|
|
func _on_tux_mouse_exited() -> void:
|
|
$Tux.modulate = Color(1.0, 1.0, 1.0)
|
|
func _on_xenia_mouse_exited() -> void:
|
|
$Xenia.modulate = Color(1.0, 1.0, 1.0)
|
|
|
|
|
|
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()
|
|
$Error.text = ""
|
|
else:
|
|
$Error.text = "No tens prou Diners!!!!"
|
|
|
|
func _on_xenia_upgrades_item_clicked(index: int, at_position: Vector2, mouse_button_index: int) -> void:
|
|
var upgrade = $XeniaUpgrades.get_item_metadata(index)
|
|
if upgrade.cost <= special_currency:
|
|
upgrade.enabled = true;
|
|
special_currency -= upgrade.cost
|
|
populate()
|
|
$Error.text = ""
|
|
else:
|
|
$Error.text = "No tens prou 🥘!!!!"
|
|
|
|
|
|
func _on_tux_pressed() -> void:
|
|
$Tux.visible = false
|
|
$Xenia.visible = false
|
|
$TuxUpgrades.visible = true
|
|
|
|
func _on_xenia_pressed():
|
|
$Tux.visible = false
|
|
$Xenia.visible = false
|
|
$XeniaUpgrades.visible = true
|
|
|
|
|
|
func _on_continue_pressed() -> void:
|
|
$Error.text = ""
|
|
$Tux.visible = true
|
|
$Xenia.visible = true
|
|
$TuxUpgrades.visible = false
|
|
$XeniaUpgrades.visible = false
|
|
shop_exit.emit()
|