From dbdd29f0ff52f1e0ac25e0aa0efb66051bcbe184 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 15 Mar 2026 23:38:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8A=80=E8=83=BD):=20=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E6=8C=81=E7=BB=AD=E6=97=B6=E9=97=B4=E8=87=B3?= =?UTF-8?q?=E5=B0=91=E4=B8=BA1=E5=B8=A7=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=94=BB=E5=87=BB=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将技能总时间的最小值从0改为1,避免除零错误。新增hitInterval字段控制攻击间隔,默认至少0.5秒。在STimeSystem中添加周期性攻击逻辑,通过pendingClose标志管理碰撞器状态。 --- assets/script/game/skill/STimeComp.ts | 16 ++++++++++++++++ assets/script/game/skill/Skill.ts | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/script/game/skill/STimeComp.ts b/assets/script/game/skill/STimeComp.ts index 8a00f535..01d36249 100644 --- a/assets/script/game/skill/STimeComp.ts +++ b/assets/script/game/skill/STimeComp.ts @@ -7,11 +7,17 @@ export class StimeDataComp extends ecs.Comp { s_uuid: number = 0; totalTime: number = 0; elapsedTime: number = 0; + hitInterval: number = 0; + hitElapsed: number = 0; + pendingClose: boolean = false; reset() { this.s_uuid = 0; this.totalTime = 0; this.elapsedTime = 0; + this.hitInterval = 0; + this.hitElapsed = 0; + this.pendingClose = false; } } @@ -29,12 +35,22 @@ export class STimeSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (!timeComp || !skillView) return; const conf = SkillSet[timeComp.s_uuid]; if (!conf || conf.EType !== EType.timeEnd) return; + if (timeComp.pendingClose) { + skillView.close_collider(); + timeComp.pendingClose = false; + } if (timeComp.totalTime <= 0) { skillView.close_collider(); entity.destroy(); return; } timeComp.elapsedTime += this.dt; + timeComp.hitElapsed += this.dt; + if (timeComp.hitInterval > 0 && timeComp.hitElapsed >= timeComp.hitInterval && !timeComp.pendingClose) { + timeComp.hitElapsed -= timeComp.hitInterval; + skillView.atk(null); + timeComp.pendingClose = true; + } if (timeComp.elapsedTime >= timeComp.totalTime) { skillView.close_collider(); entity.destroy(); diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index ecc91009..94ce2c6a 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -150,7 +150,8 @@ export class Skill extends ecs.Entity { if (!sTimeCom) sTimeCom = this.add(StimeDataComp); sTimeCom.reset(); sTimeCom.s_uuid = s_uuid; - sTimeCom.totalTime = Math.max(0, config.time ?? 0); + sTimeCom.totalTime = Math.max(1, config.time ?? 0); + sTimeCom.hitInterval = Math.max(0.5, config.hitcd || 0); } else { const sTimeCom = this.get(StimeDataComp); if (sTimeCom) this.remove(StimeDataComp);