feat(英雄): 添加受击触发技能机制

- 在 HeroInfo 接口中添加 atked 字段,用于配置受击后触发的技能
- 在 HeroAtkSystem 中实现 checkAndTriggerAtkedSkills 方法,检查受击次数并触发对应技能
- 在伤害计算逻辑中增加受击计数并调用触发检查
This commit is contained in:
panw
2026-04-15 10:55:51 +08:00
parent 4995097606
commit 9148c830c2
2 changed files with 22 additions and 0 deletions

View File

@@ -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();