TowerDefense/UI/tower_button.gd
2025-08-29 20:07:36 +02:00

20 lines
483 B
GDScript

@tool
extends Button
class_name TowerButton
var towerType : Tower.TYPES
func _ready() -> void:
#font_outline_color = Color.YELLOW
if not Engine.is_editor_hint():
pressed.connect(EventBus.tower_selected.emit.bind(towerType))
EventBus.energy_has_changed.connect(changeEnergy)
func changeEnergy(tower : Tower) -> void:
if tower.tower_type == towerType:
$ProgressBar.value = tower.energy
func setButtonTexture(texture : Texture2D) -> void:
$TextureRect.texture = texture