20 lines
482 B
GDScript
20 lines
482 B
GDScript
@tool
|
|
extends Button
|
|
class_name TowerButton
|
|
|
|
var towerType : Tower.TYPE
|
|
|
|
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
|