TowerDefense/UI/tower_button.gd

21 lines
483 B
GDScript3
Raw Normal View History

2025-08-29 20:07:36 +02:00
@tool
2025-04-02 18:02:13 +02:00
extends Button
class_name TowerButton
2025-04-02 18:02:13 +02:00
2025-08-29 20:07:36 +02:00
var towerType : Tower.TYPES
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