extends Control @onready var mp_scene: PackedScene = preload("res://scene/ui/item/mp_item.tscn") @onready var hp_bar: TextureProgressBar = $HpBar as TextureProgressBar @onready var mp_sub_bar: TextureProgressBar = $MpSubBar as TextureProgressBar @onready var mp_list: HBoxContainer = $MpList as HBoxContainer #debug info @onready var debug_info_scene: PackedScene = preload("res://scene/ui/item/debug_info_item_sub.tscn") @onready var debug_info_list: VBoxContainer = $DebugInfoList as VBoxContainer var debug_info_dict: Dictionary[String, DebugInfoItemSub] = {} func _process(_delta: float) -> void: var player: Character = Global.character_mgr.get_player() if not player: return refresh_debug_info("硬直等级", str(player.get_status("break_level"))) refresh_debug_info("姿态", str(player.get_status("stance"))) refresh_debug_info("关卡位置", Global.level_mgr.get_cur_level_name() + str(Util.get_level_grid_pos2(player.pos()))) refresh_debug_info("动画状态", ("地面" if player.get_status("is_on_floor") else "空中") + "-" + player.get_status("current_animation")) func refresh_debug_info(label_value: String, value: String) -> void: if not debug_info_dict.has(label_value): var debug_info: DebugInfoItemSub = debug_info_scene.instantiate() as DebugInfoItemSub debug_info.init(label_value) debug_info_list.add_child(debug_info) debug_info_dict[label_value] = debug_info debug_info_dict[label_value].set_value(value) func on_hp_max_changed(value: float): hp_bar.max_value = value func on_hp_changed(value: float): hp_bar.value = value func on_mp_sub_max_changed(value: float): mp_sub_bar.max_value = value func on_mp_sub_changed(value: float): mp_sub_bar.value = value func on_mp_max_changed(value: int): for child in mp_list.get_children(): child.queue_free() for i in range(value): var mp_item: MpItemSub = mp_scene.instantiate() as MpItemSub mp_list.add_child(mp_item) func on_mp_changed(value: int): for i in range(mp_list.get_child_count()): var mp_item: MpItemSub = mp_list.get_child(i) as MpItemSub mp_item.set_active(i < value)