|
|
|
|
extends Control
|
|
|
|
|
class_name Headbar
|
|
|
|
|
|
|
|
|
|
@onready var hit_text_scene: PackedScene = preload("res://scene/ui/item/hit_text.tscn")
|
|
|
|
|
@onready var hp_bar: TextureProgressBar = (%HpBar as TextureProgressBar)
|
|
|
|
|
@onready var shield_bar: TextureProgressBar = (%ShieldBar as TextureProgressBar)
|
|
|
|
|
@onready var stun_bar: TextureProgressBar = (%StunBar as TextureProgressBar)
|
|
|
|
|
@onready var mp_bar: TextureProgressBar = (%MpBar as TextureProgressBar)
|
|
|
|
|
@onready var mp_sub_bar: TextureProgressBar = (%MpSubBar as TextureProgressBar)
|
|
|
|
|
@onready var pos_lable: Label = (%PosLabel as Label)
|
|
|
|
|
@onready var role_lable: Label = (%RoleLabel as Label)
|
|
|
|
|
|
|
|
|
|
var hit_text_damage_cache: HitText
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_hp_changed(value): hp_bar.value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_hp_max_changed(value): hp_bar.max_value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_shield_changed(value):
|
|
|
|
|
shield_bar.value = value
|
|
|
|
|
shield_bar.visible = value > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_shield_max_changed(value): shield_bar.max_value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_stun_changed(value): stun_bar.value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_stun_max_changed(value): stun_bar.max_value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_mp_changed(value): mp_bar.value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_mp_max_changed(value): mp_bar.max_value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_mp_sub_changed(value): mp_sub_bar.value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_mp_sub_max_changed(value): mp_sub_bar.max_value = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_pos2d_changed(value): pos_lable.text = "(%.2f,%.2f)"%[value.x, value.y]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_ai_role_changed(value): role_lable.text = str(value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_hit_text(value: String):
|
|
|
|
|
var hit_text: HitText = get_hit_text_object()
|
|
|
|
|
hit_text.show_hit_text(value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_hit_damage(value: float):
|
|
|
|
|
var hit_text: HitText = 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: HitText = hit_text_scene.instantiate() as HitText
|
|
|
|
|
add_child(hit_text)
|
|
|
|
|
return hit_text
|