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.

64 lines
2.1 KiB
GDScript

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
9 months ago
#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
9 months ago
var debug_info_dict: Dictionary[String, DebugInfoItemSub] = {}
9 months ago
func _process(_delta: float) -> void:
var player: Character = Global.character_mgr.get_player()
9 months ago
if not player:
return
9 months ago
refresh_debug_info("硬直等级", str(player.get_status("break_level")))
refresh_debug_info("姿态", str(player.get_status("stance")))
refresh_debug_info("位置", str(player.pos()))
refresh_debug_info("关卡", Global.level_mgr.get_cur_level_name())
refresh_debug_info("关卡坐标", str(Util.get_level_grid_pos2(player.pos())))
refresh_debug_info("关卡浮点坐标", str(Util.get_level_float_pos2(Util.get_level_grid_pos2(player.pos()))))
9 months ago
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)
2 years ago
func on_hp_max_changed(value: float):
hp_bar.max_value = value
2 years ago
func on_hp_changed(value: float):
hp_bar.value = value
2 years ago
func on_mp_sub_max_changed(value: float):
mp_sub_bar.max_value = value
2 years ago
func on_mp_sub_changed(value: float):
mp_sub_bar.value = value
2 years ago
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)
2 years ago
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)