From e296ca7d7861247042f87737441513f2e18942a5 Mon Sep 17 00:00:00 2001 From: walkpan Date: Tue, 14 Apr 2026 08:37:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=88=98=E6=96=97=E5=BC=80=E5=A7=8B/?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=8A=80=E8=83=BD=E8=A7=A6=E5=8F=91=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 MissionComp 的 to_fight 和 enterPreparePhase 方法中,分别调用 triggerHeroBattleSkills 来触发英雄配置的战斗开始(fstart)和战斗结束(fend)技能。这通过查询英雄实体并派发 TriggerSkill 事件实现,使英雄能在战斗状态切换时自动释放特定技能。 --- assets/script/game/map/MissionComp.ts | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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;