You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
GDScript
34 lines
1.1 KiB
GDScript
extends Control
|
|
class_name Headbar
|
|
|
|
@onready var hit_text_scene = preload("res://scene/ui/item/hit_text.tscn")
|
|
|
|
@onready var hpbar = (%HpBar as TextureProgressBar)
|
|
@onready var shieldbar = (%ShieldBar as TextureProgressBar)
|
|
@onready var stunbar = (%StunBar as TextureProgressBar)
|
|
|
|
var hit_text_damage_cache : HitText
|
|
|
|
func on_hp_changed(value):hpbar.value = value
|
|
func on_hp_max_changed(value):hpbar.max_value = value
|
|
func on_shield_changed(value):shieldbar.value = value
|
|
func on_shield_max_changed(value):shieldbar.max_value = value
|
|
func on_stun_changed(value):stunbar.value = value
|
|
func on_stun_max_changed(value):stunbar.max_value = value
|
|
|
|
func on_hit_text(value:String):
|
|
var hit_text = get_hit_text_object()
|
|
hit_text.show_hit_text(value)
|
|
|
|
func on_hit_danage(value:float):
|
|
var hit_text = hit_text_damage_cache
|
|
if not hit_text or hit_text.is_close:
|
|
hit_text_damage_cache = get_hit_text_object()
|
|
hit_text = hit_text_damage_cache
|
|
hit_text.show_hit_damage(value)
|
|
|
|
func get_hit_text_object()->HitText:
|
|
var hit_text = hit_text_scene.instantiate() as HitText
|
|
add_child(hit_text)
|
|
return hit_text
|