2025-08-29 20:07:36 +02:00
|
|
|
@tool
|
2025-04-02 18:02:13 +02:00
|
|
|
extends Button
|
2025-06-05 15:35:19 +02:00
|
|
|
class_name TowerButton
|
2025-04-02 18:02:13 +02:00
|
|
|
|
2025-08-31 21:26:02 +02:00
|
|
|
var towerType : Tower.TYPE
|
2025-04-02 18:02:13 +02:00
|
|
|
|
2025-08-29 20:07:36 +02:00
|
|
|
func _ready() -> void:
|
2025-08-29 12:11:51 +02:00
|
|
|
#font_outline_color = Color.YELLOW
|
2025-08-29 20:07:36 +02:00
|
|
|
if not Engine.is_editor_hint():
|
|
|
|
|
pressed.connect(EventBus.tower_selected.emit.bind(towerType))
|
|
|
|
|
EventBus.energy_has_changed.connect(changeEnergy)
|
2025-08-29 12:11:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func changeEnergy(tower : Tower) -> void:
|
|
|
|
|
if tower.tower_type == towerType:
|
|
|
|
|
$ProgressBar.value = tower.energy
|
2025-08-29 20:07:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func setButtonTexture(texture : Texture2D) -> void:
|
|
|
|
|
$TextureRect.texture = texture
|