1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-04 10:47:13 +08:00

feat(UI): 添加显示实体属性的面板和动画效果

添加新的输入动作"showFields"用于显示/隐藏实体属性面板
创建新的FieldShow组件用于显示实体属性值
为属性面板添加显示/隐藏动画效果
调整EntityBase中属性初始化的顺序
This commit is contained in:
2025-08-28 13:58:31 +08:00
parent 62aa9995a9
commit aa533509a5
7 changed files with 194 additions and 31 deletions
+11 -3
View File
@@ -4,6 +4,7 @@ class_name FieldShow
@export var field: FieldStore.Entity = FieldStore.Entity.MAX_HEALTH
@export var value: float = 0
@export var showSign: bool = true
@onready var nameLabel: Label = $"%name"
@onready var valueLabel: Label = $"%value"
@@ -13,9 +14,16 @@ func _ready():
var formattedValue: String
var dataType = FieldStore.entityMapType[field]
if dataType == FieldStore.DataType.VALUE:
formattedValue = MathTool.signBeforeStr(value)
formattedValue = "%s" % (MathTool.signBeforeStr(value) if showSign else str(value))
elif dataType == FieldStore.DataType.ANGLE:
formattedValue = MathTool.signBeforeStr(value) + "°"
formattedValue = "%s°" % (MathTool.signBeforeStr(value) if showSign else str(value))
elif dataType == FieldStore.DataType.PERCENT:
formattedValue = MathTool.signBeforeStr(float("%.1f" % (value * 100))) + "%"
formattedValue = (MathTool.signBeforeStr(value * 100) if showSign else str(value * 100)) + "%"
valueLabel.text = formattedValue
static func create(newField: FieldStore.Entity, newValue: float, newShowSign: bool) -> FieldShow:
var fieldShow = preload("res://components/UI/FieldShow.tscn").instantiate()
fieldShow.field = newField
fieldShow.value = newValue
fieldShow.showSign = newShowSign
return fieldShow