TowerDefense/Tiles/cube.gd

34 lines
643 B
GDScript3
Raw Normal View History

extends StaticBody3D
class_name TheCube
@export var max_health : int = 50
var health : int = max_health :
set(value):
health = value
EventBus.cube_integrity_changed.emit(health, max_health)
if health <= 0:
death()
@export var money : int = 100 :
set(value):
money = value
EventBus.money_changed.emit(money)
func _ready() -> void:
call_deferred("display_money_on_first_call")
#Because I can't connect properly on first frame and send money info
func display_money_on_first_call() -> void:
EventBus.money_changed.emit(money)
func take_damage(damage : int) -> void:
health -= damage
func death():
print("GAME OVER")