feat: 添加玩家和敌人血条
This commit is contained in:
@@ -6,3 +6,16 @@ class_name Unit
|
||||
@onready var visuals: Node2D = %Visuals
|
||||
@onready var sprite: Sprite2D = %Sprite
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var health_component: HealthComponent = $HealthComponent
|
||||
|
||||
func _ready() -> void:
|
||||
print(stats)
|
||||
health_component.setup(stats)
|
||||
|
||||
|
||||
func _on_hurtbox_component_on_damaged(hitbox: HitboxComponent) -> void:
|
||||
if health_component.current_health <=0:
|
||||
return
|
||||
|
||||
health_component.take_damage(hitbox.damage)
|
||||
print("%s: %d" % [name, health_component.current_health] )
|
||||
|
||||
Reference in New Issue
Block a user