1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(UI): 为ColorBar添加currentValue属性并完善boss血条逻辑

为ColorBar组件添加currentValue属性以跟踪当前值。同时修复当设置boss时未正确更新血条显示的问题,确保boss血条在切换目标时能正确显示初始血量。
This commit is contained in:
2025-08-28 07:35:34 +08:00
parent ef03aa2922
commit dfbacb0098
3 changed files with 4 additions and 4 deletions
+1
View File
@@ -36,6 +36,7 @@ anchors_preset = 0
offset_right = 100.0
offset_bottom = 10.0
script = ExtResource("1_a106p")
currentValue = 0.0
backBox = SubResource("StyleBoxFlat_kf2fc")
middleBox1 = SubResource("StyleBoxFlat_sh754")
middleBox2 = SubResource("StyleBoxFlat_8n8i8")
+1 -3
View File
@@ -4,9 +4,7 @@ class_name BossBar
@onready var nameLabel: Label = $"%name"
@onready var valueLabel: Label = $"%value"
func _ready():
if is_instance_valid(entity):
nameLabel.text = entity.displayName
func _process(_delta):
if is_instance_valid(entity):
nameLabel.text = entity.displayName
valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100)
+2 -1
View File
@@ -202,8 +202,9 @@ func findWeaponAnchor(weaponName: String):
return Vector2.ZERO
func setBoss(boss: EntityBase):
currentFocusedBoss = boss
if isPlayer():
if isPlayer() and boss and UIState.bossbar.entity != boss:
UIState.bossbar.entity = boss
boss.healthChanged.emit(boss.health)
func playSound(type: String):
var body = sounds.get_node_or_null(type)
if body is AudioStreamPlayer2D: