26 lines
653 B
GDScript
26 lines
653 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)
|
|
EventBus.tower_builded.connect(towerBuilded)
|
|
|
|
|
|
func changeEnergy(tower : Tower) -> void:
|
|
if tower.tower_type == towerType:
|
|
$ProgressBar.value = tower.energy
|
|
|
|
|
|
func towerBuilded(tower : Tower) -> void :
|
|
if tower.tower_type == towerType:
|
|
$ProgressBar.max_value = tower.max_energy
|
|
|
|
|
|
func setButtonTexture(texture : Texture2D) -> void:
|
|
$TextureRect.texture = texture
|