mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-07 20:27:13 +08:00
feat: 更新UI和角色逻辑,优化能量条显示和状态管理
This commit is contained in:
@@ -6,7 +6,8 @@ class_name ColorBar
|
||||
@export var maxValue: float = 100
|
||||
@export var currentValue: float = 50
|
||||
@export var backBox: StyleBox
|
||||
@export var middleBox: StyleBox
|
||||
@export var middleBox1: StyleBox
|
||||
@export var middleBox2: StyleBox
|
||||
@export var frontBox: StyleBox
|
||||
@export var speed1: float = 0.8
|
||||
@export var speed2: float = 0.01
|
||||
@@ -18,6 +19,8 @@ var forwardDirection = -1
|
||||
func getPercent(value: float):
|
||||
return (value - minValue) / (maxValue - minValue)
|
||||
func setCurrent(value: float):
|
||||
if value == currentValue:
|
||||
return
|
||||
forwardDirection = sign(value - currentValue)
|
||||
currentValue = value
|
||||
|
||||
@@ -26,7 +29,7 @@ func _ready():
|
||||
frontValue = currentValue
|
||||
func _draw():
|
||||
draw_style_box(backBox, Rect2(0, 0, size.x, size.y))
|
||||
draw_style_box(middleBox, Rect2(0, 0, size.x * getPercent(middleValue), size.y))
|
||||
draw_style_box(middleBox2 if forwardDirection > 0 else middleBox1, Rect2(0, 0, size.x * getPercent(middleValue), size.y))
|
||||
draw_style_box(frontBox, Rect2(0, 0, size.x * getPercent(frontValue), size.y))
|
||||
func _physics_process(_delta: float) -> void:
|
||||
middleValue = lerpf(middleValue, currentValue, speed1 if forwardDirection > 0 else speed2)
|
||||
|
||||
Reference in New Issue
Block a user