mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat(EntityBase): 为energyChanged信号添加dontChangeDirection参数
添加dontChangeDirection参数以控制能量变化时的方向动画显示。当该参数为true时,直接更新能量值而不播放动画效果。
This commit is contained in:
@@ -5,7 +5,7 @@ signal hit(damage: float, bullet: BulletBase, crit: bool)
|
||||
signal healed(amount: float)
|
||||
signal healthChanged(health: float)
|
||||
|
||||
signal energyChanged(energy: float)
|
||||
signal energyChanged(energy: float, dontChangeDirection: bool)
|
||||
|
||||
const TITLE_FLAG = INF
|
||||
var fields = {
|
||||
@@ -104,9 +104,12 @@ func _ready():
|
||||
statebar.levelLabels.hide()
|
||||
UIState.player = self
|
||||
energyChanged.connect(
|
||||
func(newEnergy):
|
||||
func(newEnergy, dontChangeDirection):
|
||||
UIState.energyPercent.maxValue = fields.get(FieldStore.Entity.MAX_ENERGY)
|
||||
UIState.energyPercent.setCurrent(newEnergy)
|
||||
if dontChangeDirection:
|
||||
UIState.energyPercent.currentValue = newEnergy
|
||||
else:
|
||||
UIState.energyPercent.setCurrent(newEnergy)
|
||||
)
|
||||
else:
|
||||
currentFocusedBoss = get_tree().get_nodes_in_group("players")[0]
|
||||
@@ -186,9 +189,9 @@ func takeDamage(bullet: BulletBase, crit: bool):
|
||||
func collectItem(itemType: ItemStore.ItemType, amount: int):
|
||||
inventory[itemType] += amount
|
||||
playSound("collect")
|
||||
func storeEnergy(value: float):
|
||||
func storeEnergy(value: float, dontChangeDirection: bool = false):
|
||||
energy += value * fields.get(FieldStore.Entity.ENERGY_MULTIPILER)
|
||||
energyChanged.emit(energy)
|
||||
energyChanged.emit(energy, dontChangeDirection)
|
||||
func useEnergy(value: float):
|
||||
value /= fields.get(FieldStore.Entity.SAVE_ENERGY)
|
||||
var state = energy >= value
|
||||
|
||||
Reference in New Issue
Block a user