From 76e87ac90e582a4d0cd8d786c069f7e4a346b341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Wed, 1 Oct 2025 08:22:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=BB=E5=87=BB=E9=80=9F=E5=BA=A6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在Weapon.gd中根据实体攻击速度调整冷却时间 在CooldownTimer.gd中新增speedScale属性和centralTime方法 --- scripts/Statemachine/CooldownTimer.gd | 5 ++++- scripts/Structs/Weapon.gd | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Statemachine/CooldownTimer.gd b/scripts/Statemachine/CooldownTimer.gd index 332bd09..b98f5e6 100644 --- a/scripts/Statemachine/CooldownTimer.gd +++ b/scripts/Statemachine/CooldownTimer.gd @@ -2,12 +2,15 @@ class_name CooldownTimer var cooldown: float = 100 var lastStart: int = 0 +var speedScale: float = 1 func _init(cd: float = 100): cooldown = cd +func centralTime(): + return cooldown / speedScale func isCooldowned(): - return timeSinceLastStart() >= cooldown + return timeSinceLastStart() >= centralTime() func start(): var state = isCooldowned() if state: diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index ec45ccd..f3b30e9 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -171,6 +171,7 @@ func playSound(sound: String): await cloned.finished cloned.queue_free() func tryAttack(entity: EntityBase): + cooldownTimer.speedScale = entity.fields.get(FieldStore.Entity.ATTACK_SPEED) if cooldownTimer.start(): if entity.useEnergy(needEnergy): return await attack(entity)