2025-08-29 20:07:36 +02:00
|
|
|
@tool
|
2025-08-26 19:26:36 +02:00
|
|
|
extends Control
|
|
|
|
|
|
2025-09-04 17:59:23 +02:00
|
|
|
const BUTTON_QTY = 4
|
2025-08-29 20:07:36 +02:00
|
|
|
|
2025-09-02 19:49:40 +02:00
|
|
|
const guiButton : PackedScene = preload("res://UI/gui_button.tscn")
|
2025-08-29 20:07:36 +02:00
|
|
|
|
2025-09-02 19:49:40 +02:00
|
|
|
@onready var buttonContainer = %ButtonContainer
|
2025-09-03 03:44:44 +02:00
|
|
|
@onready var moneyLabel = %LabelMoney
|
|
|
|
|
@onready var towerInCubeLabel = %LabelTowerInCube
|
|
|
|
|
@onready var towerOnTerrainLabel = %LabelTowerOnTerrain
|
2025-09-03 20:52:14 +02:00
|
|
|
@onready var cubeIntegrity = %CubeIntegrity
|
2025-08-27 13:27:32 +02:00
|
|
|
|
2025-08-30 00:46:34 +02:00
|
|
|
|
2025-08-27 13:27:32 +02:00
|
|
|
func _ready() -> void:
|
2025-08-29 20:07:36 +02:00
|
|
|
addTowerButtonNodes()
|
2025-09-03 03:44:44 +02:00
|
|
|
EventBus.team_in_rest_changed.connect(func(count): towerInCubeLabel.text = str(count) + " x Zzz")
|
|
|
|
|
EventBus.team_in_action_changed.connect(func(count): towerOnTerrainLabel.text = str(count) + " in action")
|
2025-09-04 17:59:23 +02:00
|
|
|
Game.allowed_tower_has_change.connect(addTowerButtonNodes)
|
|
|
|
|
Game.cube_integrity_changed.connect(func(): cubeIntegrity.value = Game.healthPercentage)
|
|
|
|
|
Game.money_changed.connect(func(): moneyLabel.text = str(Game.money) + " €")
|
|
|
|
|
cubeIntegrity.max_value = Game.max_health
|
2025-08-29 20:07:36 +02:00
|
|
|
|
2025-08-26 19:26:36 +02:00
|
|
|
|
|
|
|
|
func _on_button_cube_pressed() -> void:
|
|
|
|
|
pass # Replace with function body.
|
2025-08-27 13:27:32 +02:00
|
|
|
|
|
|
|
|
|
2025-09-03 20:52:14 +02:00
|
|
|
func quitLevel() -> void:
|
2025-08-27 13:27:32 +02:00
|
|
|
Transition.goto("res://UI/start_menu.tscn")
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 20:52:14 +02:00
|
|
|
func quitGame() -> void:
|
2025-08-27 13:27:32 +02:00
|
|
|
get_tree().quit()
|
2025-08-29 20:07:36 +02:00
|
|
|
|
2025-08-30 00:46:34 +02:00
|
|
|
|
2025-08-29 20:07:36 +02:00
|
|
|
func addTowerButtonNodes() -> void:
|
|
|
|
|
for node in buttonContainer.get_children():
|
|
|
|
|
if node.has_meta("dynamicButton"):
|
|
|
|
|
node.queue_free()
|
|
|
|
|
|
2025-08-30 00:46:34 +02:00
|
|
|
var additionalPlaceholder : int = 0
|
2025-09-04 17:59:23 +02:00
|
|
|
for towerType : int in Tower.TYPE.values() :
|
|
|
|
|
if towerType && (Engine.is_editor_hint() || Game.allowedTowers.has(towerType)):
|
2025-09-01 17:32:21 +02:00
|
|
|
createTowerButton(towerType)
|
|
|
|
|
|
2025-09-04 17:59:23 +02:00
|
|
|
for i in BUTTON_QTY - (buttonContainer.get_children().size() % BUTTON_QTY):
|
|
|
|
|
createTowerButton(Tower.TYPE.NONE)
|
2025-09-01 17:32:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func createTowerButton(towerType : Tower.TYPE) -> void:
|
2025-09-04 17:59:23 +02:00
|
|
|
var btn : GuiButton = guiButton.instantiate()
|
|
|
|
|
btn.set_meta("dynamicButton", true)
|
|
|
|
|
|
|
|
|
|
if towerType:
|
|
|
|
|
var tower : PackedScene = Game.towerPackedScenes.get(towerType)
|
|
|
|
|
btn.towerType = towerType
|
|
|
|
|
btn.tooltip_text = str(EnhancedResource.getPackedSceneProperty(tower, "name"))
|
|
|
|
|
btn.texture = EnhancedResource.getPackedSceneProperty(tower, "icone")
|
|
|
|
|
else:
|
|
|
|
|
btn.disabled = true
|
|
|
|
|
buttonContainer.add_child(btn)
|