diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index c9e12649..e7f336e6 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -38,6 +38,7 @@ import { HeroViewComp } from "../hero/HeroViewComp"; import { UIID } from "../common/config/GameUIConfig"; import { SkillView } from "../skill/SkillView"; import { FacSet, FightSet } from "../common/config/GameSet"; +import { HeroInfo } from "../common/config/heroSet"; import { mLogger } from "../common/Logger"; import { Monster } from "../hero/Mon"; import { Skill } from "../skill/Skill"; @@ -248,6 +249,7 @@ export class MissionComp extends CCComp { * - 标记战斗中 * - 隐藏开始按钮 * - 分发 FightStart 事件 + * - 触发英雄战斗开始技能 */ to_fight(){ smc.mission.stop_spawn_mon = false; @@ -255,6 +257,7 @@ export class MissionComp extends CCComp { smc.vmdata.mission_data.in_fight = true if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; oops.message.dispatchEvent(GameEvent.FightStart) + this.triggerHeroBattleSkills(true); } /** @@ -262,14 +265,39 @@ export class MissionComp extends CCComp { * - 标记非战斗 * - 暂停刷怪 * - 显示开始按钮 + * - 触发英雄战斗结束技能 */ private enterPreparePhase() { + this.triggerHeroBattleSkills(false); smc.mission.in_fight = false; smc.vmdata.mission_data.in_fight = false smc.mission.stop_spawn_mon = true; if (this.start_btn && this.start_btn.isValid) this.start_btn.active = true; } + /** + * 触发英雄的战斗开始/结束技能 + * @param isStart 是否为战斗开始 + */ + private triggerHeroBattleSkills(isStart: boolean) { + ecs.query(this.heroAttrsMatcher).forEach(entity => { + const attrs = entity.get(HeroAttrsComp); + const view = entity.get(HeroViewComp); + if (!attrs || !view || attrs.is_dead || attrs.fac !== FacSet.HERO) return; + const info = HeroInfo[attrs.hero_uuid]; + if (!info) return; + const skillUuid = isStart ? info.fstart : info.fend; + if (skillUuid) { + oops.message.dispatchEvent(GameEvent.TriggerSkill, { + s_uuid: skillUuid, + heroAttrs: attrs, + heroView: view, + triggerType: isStart ? 'fstart' : 'fend' + }); + } + }); + } + /** 开始战斗按钮点击回调 */ private onStartFightBtnClick() { if (!smc.mission.play) return;