fix(战斗逻辑): 修复非战斗状态下技能释放和状态同步问题

- 在 SCastSystem 中增加战斗状态检查,防止非战斗时误触发技能
- 同步 mission.in_fight 状态到 vmdata.mission_data.in_fight 以保持数据一致性
- 调整 MissionCardComp 在波次开始时正确布局卡牌槽位并分发卡牌
- 优化游戏地平线位置和 UI 布局参数
This commit is contained in:
panw
2026-03-27 09:31:40 +08:00
parent 0b20d773d2
commit a42d34b003
5 changed files with 13 additions and 3 deletions

View File

@@ -1267,7 +1267,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -170, "y": -130,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -1383,7 +1383,7 @@
"_left": 0, "_left": 0,
"_right": 0, "_right": 0,
"_top": 0, "_top": 0,
"_bottom": -120, "_bottom": -80,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,

View File

@@ -11,7 +11,7 @@ export enum BoxSet {
LETF_END = -420, LETF_END = -420,
RIGHT_END = 420, RIGHT_END = 420,
//游戏地平线 //游戏地平线
GAME_LINE = -40, GAME_LINE = 0,
//攻击距离 //攻击距离
} }

View File

@@ -53,6 +53,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
update(e: ecs.Entity): void { update(e: ecs.Entity): void {
if(!smc.mission.play ) return; if(!smc.mission.play ) return;
if(smc.mission.pause) return if(smc.mission.pause) return
if(!smc.mission.in_fight) return
const heroAttrs = e.get(HeroAttrsComp); const heroAttrs = e.get(HeroAttrsComp);
const heroView = e.get(HeroViewComp); const heroView = e.get(HeroViewComp);
if (!heroAttrs || !heroView || !heroView.node) return; if (!heroAttrs || !heroView || !heroView.node) return;
@@ -107,6 +108,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
* - 触发技能CD * - 触发技能CD
*/ */
private castSkill(castPlan: { skillId: number; skillLv: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { private castSkill(castPlan: { skillId: number; skillLv: number; isFriendly: boolean; targetPos: Vec3 | null; targetEids: number[] }, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
if (!smc.mission.in_fight) return;
const s_uuid = castPlan.skillId; const s_uuid = castPlan.skillId;
const skillLv = castPlan.skillLv; const skillLv = castPlan.skillLv;
const config = SkillSet[s_uuid]; const config = SkillSet[s_uuid];
@@ -124,9 +126,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const delay = config.ready > 0 ? config.ready : GameConst.Battle.SKILL_CAST_DELAY; const delay = config.ready > 0 ? config.ready : GameConst.Battle.SKILL_CAST_DELAY;
heroView.scheduleOnce(() => { heroView.scheduleOnce(() => {
if (!smc.mission.play || smc.mission.pause || !smc.mission.in_fight) return;
if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return; if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return;
const castTimes = 1 + cNum; const castTimes = 1 + cNum;
for (let i = 0; i < castTimes; i++) { for (let i = 0; i < castTimes; i++) {
if (!smc.mission.play || smc.mission.pause || !smc.mission.in_fight) return;
if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return; if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return;
if (castPlan.isFriendly) { if (castPlan.isFriendly) {
const friendlyTargets = this.resolveFriendlyTargets(castPlan.targetEids, heroAttrs.fac); const friendlyTargets = this.resolveFriendlyTargets(castPlan.targetEids, heroAttrs.fac);

View File

@@ -178,6 +178,9 @@ export class MissionCardComp extends CCComp {
private onNewWave() { private onNewWave() {
this.enterPreparePhase(); this.enterPreparePhase();
this.layoutCardSlots();
const cards = this.buildDrawCards();
this.dispatchCardsToSlots(cards);
} }
/** 解除按钮监听,避免节点销毁后回调泄漏 */ /** 解除按钮监听,避免节点销毁后回调泄漏 */

View File

@@ -156,12 +156,14 @@ export class MissionComp extends CCComp {
to_fight(){ to_fight(){
smc.mission.stop_spawn_mon = false; smc.mission.stop_spawn_mon = false;
smc.mission.in_fight=true smc.mission.in_fight=true
smc.vmdata.mission_data.in_fight = true
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false;
oops.message.dispatchEvent(GameEvent.FightStart) //GameSetMonComp 监听刷怪 oops.message.dispatchEvent(GameEvent.FightStart) //GameSetMonComp 监听刷怪
} }
private enterPreparePhase() { private enterPreparePhase() {
smc.mission.in_fight = false; smc.mission.in_fight = false;
smc.vmdata.mission_data.in_fight = false
smc.mission.stop_spawn_mon = true; smc.mission.stop_spawn_mon = true;
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = true; if (this.start_btn && this.start_btn.isValid) this.start_btn.active = true;
} }
@@ -207,6 +209,7 @@ export class MissionComp extends CCComp {
smc.mission.play=false smc.mission.play=false
smc.mission.pause = false; smc.mission.pause = false;
smc.mission.in_fight = false; smc.mission.in_fight = false;
smc.vmdata.mission_data.in_fight = false
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false;
this.cleanComponents() this.cleanComponents()
this.clearBattlePools() this.clearBattlePools()