From e42bdbb6718a0951fa7951ebff5a6fd29acdeedf Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 19 Nov 2025 10:34:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=A4=A9=E8=B5=8B=E7=B3=BB=E7=BB=9F):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=A4=A9=E8=B5=8B=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=92=8C=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构 TalComp 类的触发检查方法,将 checkIsTrigger 拆分为 getTriggers 和 checkIsTrigger 简化 SACastSystem 中的天赋触发判断逻辑,使用新的 checkIsTrigger 返回值 --- assets/script/game/hero/SACastSystem.ts | 14 ++++----- assets/script/game/hero/TalComp.ts | 39 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/assets/script/game/hero/SACastSystem.ts b/assets/script/game/hero/SACastSystem.ts index 501ca7d0..43a6b995 100644 --- a/assets/script/game/hero/SACastSystem.ts +++ b/assets/script/game/hero/SACastSystem.ts @@ -119,14 +119,11 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat // 2. 更新攻击类型的天赋触发值 if(casterEntity.has(TalComp)){ const talComp = casterEntity.get(TalComp); - if (hset === HSSet.atk) { - talComp.updateCur(TriType.ATK); - isWFuny= talComp.checkIsTrigger(TalEffet.WFUNY); - } - if (hset != HSSet.atk) { - talComp.updateCur(TriType.SKILL); - isDSill= talComp.checkIsTrigger(TalEffet.D_SKILL); - } + if (hset === HSSet.atk) talComp.updateCur(TriType.ATK); + if (hset != HSSet.atk) talComp.updateCur(TriType.SKILL); + isDSill=talComp.checkIsTrigger().isDSill + isWFuny=talComp.checkIsTrigger().isWFuny + } @@ -149,6 +146,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat // console.log(`[SACastSystem] ${heroAttrs?.hero_name ?? '未知'} 施放技能: ${config.name}`); } + /** * 创建技能实体 */ diff --git a/assets/script/game/hero/TalComp.ts b/assets/script/game/hero/TalComp.ts index aeef4e3e..7a369805 100644 --- a/assets/script/game/hero/TalComp.ts +++ b/assets/script/game/hero/TalComp.ts @@ -129,22 +129,35 @@ export class TalComp extends ecs.Comp { // 判断是否有天赋被触发 return Triggers; } - checkIsTrigger(effet: TalEffet) { + getTriggers() { + // 存储所有触发的天赋 + let Triggers: Record = {}; + // 遍历所有天赋 for (let uuid in this.Tals) { const talent = this.Tals[uuid]; - // 匹配天赋类型 - if (talent.effet == effet) { - // 修复触发条件逻辑:累积值达到或超过触发阈值时触发 - // 原逻辑中 `talent.Trigger-talent.Trigger` 总是为0,导致任何累积值都能触发 - if (talent.cur >= (talent.Trigger - talent.Trigger_add)) { // 修复触发条件,累积值达到或超过触发阈值时触发 - console.log(`[TalComp]天赋触发,天赋ID:${uuid}`); - // 重置累积值 - talent.cur = 0; - // 添加到触发列表 - return true; - } - } + if (talent.cur >= (talent.Trigger - talent.Trigger_add)) { // 修复触发条件,累积值达到或超过触发阈值时触发 + console.log(`[TalComp]天赋触发,天赋ID:${uuid}`); + // 重置累积值 + talent.cur = 0; + // 添加到触发列表 + Triggers[uuid] = talent; + } } + // 判断是否有天赋被触发 + return Triggers; + } + checkIsTrigger() { + let res = { + isDSill:false, + isWFuny:false, + } + for(let uuid in this.Tals){ + let trigger=this.Tals[uuid] + if(trigger.effet==TalEffet.WFUNY) res.isWFuny=true + if(trigger.effet==TalEffet.D_SKILL) res.isDSill=true + + } + return res } /** * 更新天赋的效果数值