72 lines
2.3 KiB
GDScript
72 lines
2.3 KiB
GDScript
extends Control
|
|
|
|
@export var jobs_array: Array[JobData]
|
|
@export var job_limit: int = 5
|
|
@export var debug: bool = false
|
|
|
|
@onready var debug_xp: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugXP
|
|
@onready var debug_money: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugMoney
|
|
@onready var debug_button: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugButton
|
|
@onready var jobs_tab_button: Button = $VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons/JobsTabButton
|
|
|
|
const PRINTER = preload("uid://33ctlyrpibs3")
|
|
|
|
func _ready() -> void:
|
|
check_debug()
|
|
|
|
%Money.text = "Money: " + str(PlayerData.money) + " €"
|
|
%Experience.value = PlayerData.xp
|
|
%Level.text = "Level: " + str(PlayerData.level)
|
|
|
|
PlayerData.xp_changed.connect(_on_xp_changed)
|
|
PlayerData.level_changed.connect(_on_level_changed)
|
|
PlayerData.money_changed.connect(_on_money_changed)
|
|
GameData.job_generated.connect(_on_job_generated)
|
|
GameData.job_interact.connect(_on_job_interact)
|
|
|
|
# --- Experience, Level and Money update ---
|
|
func _on_xp_changed(xp):
|
|
%Experience.value = xp
|
|
func _on_level_changed(level):
|
|
%Level.text = "Level: " + str(level)
|
|
func _on_money_changed(money):
|
|
%Money.text = "Money: " + str(money) + "€"
|
|
|
|
func _on_job_generated(job: Node):
|
|
%JobContainer.add_child(job)
|
|
|
|
func _on_job_interact() -> void:
|
|
jobs_tab_button.text = "Jobs (" + str(GameData.current_job_count) + "/" + str(GameData.MAX_JOBS) + ")"
|
|
|
|
func _on_printers_printer_purchase_requested(printer_data: PrinterData) -> void:
|
|
if PlayerData.try_purchase(printer_data.printer_price):
|
|
%Money.text = "Money: " + str(PlayerData.money) + "€"
|
|
var new_printer = PRINTER.instantiate()
|
|
%PrinterContainer.add_child(new_printer)
|
|
new_printer.initialize_printer(printer_data)
|
|
|
|
#region Debug
|
|
func check_debug() -> void:
|
|
debug_xp.visible = false
|
|
debug_money.visible = false
|
|
if debug:
|
|
debug_xp.visible = true
|
|
debug_money.visible = true
|
|
|
|
func _on_debug_money_pressed() -> void:
|
|
PlayerData.give_money.emit(100)
|
|
|
|
func _on_debug_xp_pressed() -> void:
|
|
var xp = randf() * 100
|
|
PlayerData.give_experience.emit(xp)
|
|
|
|
func _on_debug_button_pressed() -> void:
|
|
toggle_debug()
|
|
|
|
func toggle_debug() -> void:
|
|
if debug == true:
|
|
debug = false
|
|
else:
|
|
debug = true
|
|
check_debug()
|
|
#endregion
|