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:
@@ -36,6 +36,7 @@ anchors_preset = 0
|
|||||||
offset_right = 100.0
|
offset_right = 100.0
|
||||||
offset_bottom = 10.0
|
offset_bottom = 10.0
|
||||||
script = ExtResource("1_a106p")
|
script = ExtResource("1_a106p")
|
||||||
|
currentValue = 0.0
|
||||||
backBox = SubResource("StyleBoxFlat_kf2fc")
|
backBox = SubResource("StyleBoxFlat_kf2fc")
|
||||||
middleBox1 = SubResource("StyleBoxFlat_sh754")
|
middleBox1 = SubResource("StyleBoxFlat_sh754")
|
||||||
middleBox2 = SubResource("StyleBoxFlat_8n8i8")
|
middleBox2 = SubResource("StyleBoxFlat_8n8i8")
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ class_name BossBar
|
|||||||
@onready var nameLabel: Label = $"%name"
|
@onready var nameLabel: Label = $"%name"
|
||||||
@onready var valueLabel: Label = $"%value"
|
@onready var valueLabel: Label = $"%value"
|
||||||
|
|
||||||
func _ready():
|
|
||||||
if is_instance_valid(entity):
|
|
||||||
nameLabel.text = entity.displayName
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if is_instance_valid(entity):
|
if is_instance_valid(entity):
|
||||||
|
nameLabel.text = entity.displayName
|
||||||
valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100)
|
valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100)
|
||||||
|
|||||||
@@ -202,8 +202,9 @@ func findWeaponAnchor(weaponName: String):
|
|||||||
return Vector2.ZERO
|
return Vector2.ZERO
|
||||||
func setBoss(boss: EntityBase):
|
func setBoss(boss: EntityBase):
|
||||||
currentFocusedBoss = boss
|
currentFocusedBoss = boss
|
||||||
if isPlayer():
|
if isPlayer() and boss and UIState.bossbar.entity != boss:
|
||||||
UIState.bossbar.entity = boss
|
UIState.bossbar.entity = boss
|
||||||
|
boss.healthChanged.emit(boss.health)
|
||||||
func playSound(type: String):
|
func playSound(type: String):
|
||||||
var body = sounds.get_node_or_null(type)
|
var body = sounds.get_node_or_null(type)
|
||||||
if body is AudioStreamPlayer2D:
|
if body is AudioStreamPlayer2D:
|
||||||
|
|||||||
Reference in New Issue
Block a user