feat(战斗): 添加英雄战斗开始/结束技能触发逻辑
在 MissionComp 的 to_fight 和 enterPreparePhase 方法中,分别调用 triggerHeroBattleSkills 来触发英雄配置的战斗开始(fstart)和战斗结束(fend)技能。这通过查询英雄实体并派发 TriggerSkill 事件实现,使英雄能在战斗状态切换时自动释放特定技能。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user