1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

feat(战斗系统): 添加攻击速度属性支持

在Weapon.gd中根据实体攻击速度调整冷却时间
在CooldownTimer.gd中新增speedScale属性和centralTime方法
This commit is contained in:
2025-10-01 08:22:37 +08:00
parent 813ecfcf69
commit 76e87ac90e
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -2,12 +2,15 @@ class_name CooldownTimer
var cooldown: float = 100 var cooldown: float = 100
var lastStart: int = 0 var lastStart: int = 0
var speedScale: float = 1
func _init(cd: float = 100): func _init(cd: float = 100):
cooldown = cd cooldown = cd
func centralTime():
return cooldown / speedScale
func isCooldowned(): func isCooldowned():
return timeSinceLastStart() >= cooldown return timeSinceLastStart() >= centralTime()
func start(): func start():
var state = isCooldowned() var state = isCooldowned()
if state: if state:
+1
View File
@@ -171,6 +171,7 @@ func playSound(sound: String):
await cloned.finished await cloned.finished
cloned.queue_free() cloned.queue_free()
func tryAttack(entity: EntityBase): func tryAttack(entity: EntityBase):
cooldownTimer.speedScale = entity.fields.get(FieldStore.Entity.ATTACK_SPEED)
if cooldownTimer.start(): if cooldownTimer.start():
if entity.useEnergy(needEnergy): if entity.useEnergy(needEnergy):
return await attack(entity) return await attack(entity)