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.

82 lines
2.2 KiB
GDScript

2 years ago
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)
1 year ago
@onready var break_level: Sprite2D = (%BreakLevel as Sprite2D)
#debug info
@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)
2 years ago
1 year ago
func set_debug_info_show(is_show: bool) -> void:
var debug_info: Control = (%DebugInfo as Control)
debug_info.visible = is_show
2 years ago
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
2 years ago
func on_shield_max_changed(value): shield_bar.max_value = value
1 year ago
func on_break_level_def_changed(value):
break_level.frame = clamp(value + 4, 0, 8)
2 years ago
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)
2 years ago
func on_hit_text(value: String):
var hit_text: HitText = get_hit_text_object()
2 years ago
hit_text.show_hit_text(value)
func on_hit_damage(value: float):
var hit_text: HitText = hit_text_damage_cache
2 years ago
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)
2 years ago
func get_hit_text_object()->HitText:
var hit_text: HitText = hit_text_scene.instantiate() as HitText
2 years ago
add_child(hit_text)
return hit_text