From 9148c830c2111898152f13f01a6b378217361d68 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 15 Apr 2026 10:55:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=97=E5=87=BB=E8=A7=A6=E5=8F=91=E6=8A=80=E8=83=BD=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 HeroInfo 接口中添加 atked 字段,用于配置受击后触发的技能 - 在 HeroAtkSystem 中实现 checkAndTriggerAtkedSkills 方法,检查受击次数并触发对应技能 - 在伤害计算逻辑中增加受击计数并调用触发检查 --- assets/script/game/common/config/heroSet.ts | 1 + assets/script/game/hero/HeroAtkSystem.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 7d97d559..93628835 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -68,6 +68,7 @@ export interface heroInfo { fstart?:number[]; // 战斗开始时释放的技能uuid列表 fend?:number[]; // 战斗结束时释放的技能uuid列表 atking?:{s_uuid:number, t_num:number}[]; // 普通攻击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的普攻次数 + atked?:{s_uuid:number, t_num:number}[]; // 受击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的受击次数 // dis: number; // 攻击距离(像素) speed: number; // 移动速度(像素/秒) skills: Record ; // 携带技能ID列表 diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 130aa466..ddbd1095 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -91,6 +91,23 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd } + /** 检查并触发受击附加技能 (atked) */ + private checkAndTriggerAtkedSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { + const heroInfo = HeroInfo[heroAttrs.hero_uuid]; + if (!heroInfo || !heroInfo.atked || heroInfo.atked.length === 0) return; + + heroInfo.atked.forEach(atkConfig => { + if (heroAttrs.atked_count > 0 && heroAttrs.atked_count % atkConfig.t_num === 0) { + oops.message.dispatchEvent(GameEvent.TriggerSkill, { + s_uuid: atkConfig.s_uuid, + heroAttrs: heroAttrs, + heroView: heroView, + triggerType: 'atked' + }); + } + }); + } + /** * 执行攻击计算 - 核心伤害计算逻辑 * @@ -143,6 +160,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // TAttrsComp.hp -= damage; // 应用伤害到数据层 TAttrsComp.add_hp(-damage); // 使用 add_hp 以触发 dirty_hp 和 UI 更新 + // 增加受击计数并触发 atked 技能 + TAttrsComp.atked_count++; + this.checkAndTriggerAtkedSkills(TAttrsComp, targetView); + // 受击者产生击退效果 // if (damage > 0 && targetView) { // targetView.back();