From 4a2768cb138771adcd2b1908935b138cd6edde9a Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 19:33:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B8=B8=E6=88=8F=E9=80=BB=E8=BE=91):?= =?UTF-8?q?=20=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8is=5Fmaster=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=8E=A9=E5=AE=B6=E8=A7=92=E8=89=B2=E5=B9=B6=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=9A=82=E5=81=9C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将多处使用FacSet.HERO判断玩家角色的代码改为使用is_master属性 将stop_mon_action控制逻辑简化为统一的pause状态管理 在MissionComp初始化时确保pause状态正确重置 --- assets/script/game/hero/HeroAtkSystem.ts | 8 ++++---- assets/script/game/hero/HeroViewComp.ts | 2 +- assets/script/game/map/MissionComp.ts | 3 ++- assets/script/game/map/VictoryComp.ts | 4 +--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index e6621422..20f6f9cd 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -204,7 +204,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 检查死亡 if (TAttrsComp.hp <= 0) { // 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活 - if (TAttrsComp.fac === FacSet.HERO && TAttrsComp.Attrs[Attrs.REVIVE_COUNT] >= 1) { + if (TAttrsComp.is_master && TAttrsComp.Attrs[Attrs.REVIVE_COUNT] >= 1) { TAttrsComp.Attrs[Attrs.REVIVE_COUNT]--; TAttrsComp.is_reviving = true; // 标记为正在复活 @@ -226,7 +226,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd if (caster) CAttrsComp.Attrs.killed_count++; // 玩家英雄死亡后,怪物停止刷新和移动 - if (TAttrsComp.fac === FacSet.HERO) { + if (TAttrsComp.is_master) { smc.mission.stop_mon_action = true; console.log("[HeroAtkSystem] Hero died, stopping monster action (spawn/move)"); } @@ -261,7 +261,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 检查死亡 if (CAttrs.hp <= 0) { // 复活机制 - if (CAttrs.fac === FacSet.HERO && CAttrs.Attrs[Attrs.REVIVE_COUNT] >= 1) { + if (CAttrs.is_master && CAttrs.Attrs[Attrs.REVIVE_COUNT] >= 1) { CAttrs.Attrs[Attrs.REVIVE_COUNT]--; CAttrs.is_reviving = true; @@ -277,7 +277,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd } // 玩家英雄死亡后,怪物停止刷新和移动 - if (CAttrs.fac === FacSet.HERO) { + if (CAttrs.is_master) { smc.mission.stop_mon_action = true; console.log("[HeroAtkSystem] Hero died from thorns, stopping monster action (spawn/move)"); } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 0e640d0f..288a2519 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -361,7 +361,7 @@ export class HeroViewComp extends CCComp { this.lastBarUpdateTime=0 // 恢复怪物行动 - if (this.model.fac === FacSet.HERO) { + if (this.model.is_master) { smc.mission.stop_mon_action = false; console.log("[HeroViewComp] Hero revived, resuming monster action"); } diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 03bb7bff..860161c4 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -162,7 +162,7 @@ export class MissionComp extends CCComp { open_Victory(e:any,is_hero_dead: boolean = false){ // 暂停游戏循环和怪物行为 // smc.mission.play = false; - smc.mission.stop_mon_action = true; + smc.mission.pause = true; // oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false}) console.log("[MissionComp] open_Victory",is_hero_dead,this.revive_times) oops.gui.open(UIID.Victory,{ @@ -203,6 +203,7 @@ export class MissionComp extends CCComp { data_init(){ //局内数据初始化 smc 数据初始化 smc.mission.play = true; + smc.mission.pause = false; smc.mission.stop_mon_action = false; smc.vmdata.mission_data.in_fight=false smc.vmdata.mission_data.fight_time=0 diff --git a/assets/script/game/map/VictoryComp.ts b/assets/script/game/map/VictoryComp.ts index 84223af8..b2de532d 100644 --- a/assets/script/game/map/VictoryComp.ts +++ b/assets/script/game/map/VictoryComp.ts @@ -51,8 +51,6 @@ export class VictoryComp extends CCComp { this.node.getChildByName("btns").getChildByName("next").active=!args.can_revive this.node.getChildByName("btns").getChildByName("alive").active=args.can_revive - smc.mission.pause=true - } @@ -99,7 +97,7 @@ export class VictoryComp extends CCComp { // 3. 恢复游戏状态 // smc.mission.play = true; - smc.mission.stop_mon_action = false; + smc.mission.pause = false; // 4. 关闭结算界面 oops.gui.removeByNode(this.node);