refactor(游戏逻辑): 统一使用is_master判断玩家角色并简化暂停逻辑
将多处使用FacSet.HERO判断玩家角色的代码改为使用is_master属性 将stop_mon_action控制逻辑简化为统一的pause状态管理 在MissionComp初始化时确保pause状态正确重置
This commit is contained in:
@@ -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)");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user