diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 2c71ea15..ad44b48f 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -39,7 +39,7 @@ export class Hero extends ecs.Entity { /** 加载角色 */ - load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,fight_pos:number=1,is_master:boolean=false,is_friend:boolean=false) { + load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) { scale = 1 // 查找空闲英雄槽位 let size=1 @@ -64,15 +64,12 @@ export class Hero extends ecs.Entity { // 设置 View 层属性(表现相关) hv.scale = 1; hv.box_group = BoxSet.HERO; - // 设置 Model 层属性(数据相关) model.hero_uuid = uuid; model.hero_name = hero.name; model.lv = hero.lv ? hero.lv : 1; model.type = hero.type; model.fac = FacSet.HERO; - model.is_master = is_master; - model.is_friend = is_friend model.rangeType = hero.rangeType; // 只有主角才挂载天赋组件 diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index cef08822..4107491d 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -172,20 +172,15 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 检查死亡 if (TAttrsComp.hp <= 0) { // 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活 - if (TAttrsComp.is_master && TAttrsComp.revive_count >= 1) { + if (TAttrsComp.revive_count >= 1) { TAttrsComp.revive_count--; TAttrsComp.is_reviving = true; // 标记为正在复活 - - // 停止怪物行动 - smc.mission.stop_mon_action = true; - // 触发死亡动画(假死) if (targetView) { targetView.do_dead(); // 延迟1秒复活 targetView.scheduleRevive(1.0); } - mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives left: ${TAttrsComp.revive_count}`); return reDate; } @@ -193,13 +188,6 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 增加被击杀计数 if (caster) CAttrsComp.killed_count++; - // 玩家英雄死亡后,怪物停止刷新和移动 - if (TAttrsComp.is_master&&TAttrsComp.revive_count <= 0) { - smc.mission.stop_mon_action = true; - oops.message.dispatchEvent(GameEvent.HeroDead, { hero_uuid: TAttrsComp.hero_uuid}); - mLogger.log(this.debugMode, 'HeroAtkSystem', " Hero died, stopping monster action (spawn/move)"+TAttrsComp.revive_count); - } - this.doDead(target); // ✅ 触发死亡视图表现 if (targetView) { diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 0783778f..9ab3c998 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -540,7 +540,6 @@ export class HeroAttrsComp extends ecs.Comp { this.is_stop = false; this.is_boss = false; this.is_big_boss = false; - this.is_master = false; this.is_friend = false; this.is_kalami = false; this.is_reviving = false; diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index d9471594..08f3a607 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -386,12 +386,7 @@ export class HeroViewComp extends CCComp { this.model.hp =this.model.hp_max*50/100; this.top_node.active=false this.lastBarUpdateTime=0 - - // 恢复怪物行动 - if (this.model.is_master) { - smc.mission.stop_mon_action = false; - mLogger.log(this.debugMode, 'HeroViewComp', "[HeroViewComp] Hero revived, resuming monster action"); - } + } /** @@ -434,28 +429,21 @@ export class HeroViewComp extends CCComp { mLogger.warn(this.debugMode, 'HeroViewComp', "[HeroViewComp] realDead called but model is null, skipping"); return; } + // 根据阵营触发不同事件 + if(this.model.fac === FacSet.MON){ + + } + if(this.model.fac === FacSet.HERO){ - // 英雄死亡:延迟触发死亡事件 - // 🔥 只有主角死亡才触发游戏结束判定 - if (this.model.is_master) return + } + // 🔥 方案B:治理性措施 - 在销毁实体前先禁用碰撞体,从源头减少"尸体"参与碰撞 const collider = this.getComponent(Collider2D); if (collider) { collider.enabled = false; } - - // 根据阵营触发不同事件 - if(this.model.fac === FacSet.MON){ - oops.message.dispatchEvent(GameEvent.MonDead, { - uuid: this.model.hero_uuid, - lv: this.model.lv, - is_boss: this.model.is_boss, - is_elite: this.model.is_big_boss, // 暂时映射 is_big_boss 为 elite,或者由 MissionComp 二次判断 - position: this.node.position - }); - } this.ent.destroy(); } diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index b27036cf..6bcd25e6 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -56,7 +56,6 @@ export class MissionComp extends CCComp { onLoad(){ this.on(GameEvent.MissionStart,this.mission_start,this) - this.on(GameEvent.MonDead,this.do_mon_dead,this) // this.on(GameEvent.HeroDead,this.do_hero_dead,this) // this.on(GameEvent.FightEnd,this.fight_end,this) this.on(GameEvent.MissionEnd,this.mission_end,this) @@ -106,31 +105,6 @@ export class MissionComp extends CCComp { // 奖励发放 } - do_mon_dead(event:any,data:any){ - // mLogger.log(this.debugMode, 'MissionComp', " do_mon_dead",event,data) - smc.vmdata.mission_data.mon_num-- - // 计算并增加经验 - // data 应该是怪物组件或包含怪物信息的对象 - if (data && data.uuid) { - // 默认值处理 - const level = data.lv || 1; - - // 类型推断 - let type = MonType.NORMAL; - if (data.is_boss) { - type = MonType.BOSS; - } else if (data.is_elite) { - type = MonType.ELITE; - } else { - // 兜底策略:根据Cost判断是否为精英怪 - const cost = MonsterCost[data.uuid] || 1;`` - if (cost >= 10) { - type = MonType.ELITE; - } - } - this.cal_gold_reward(data, type); - } - } cal_gold_reward(data: any, type: MonType) { const cost = MonsterCost[data.uuid] || 1; diff --git a/assets/script/game/map/MissionHeroComp.ts b/assets/script/game/map/MissionHeroComp.ts index 1b22d945..888488f5 100644 --- a/assets/script/game/map/MissionHeroComp.ts +++ b/assets/script/game/map/MissionHeroComp.ts @@ -22,12 +22,14 @@ export class MissionHeroCompComp extends CCComp { this.on(GameEvent.FightReady,this.fight_ready,this) this.on(GameEvent.Zhaohuan,this.zhao_huan,this) this.on(GameEvent.MissionEnd,this.clear_heros,this) - // this.on(GameEvent.CallFriend,this.call_friend,this) - oops.message.on(GameEvent.CallFriend,this.call_friend,this) + oops.message.on(GameEvent.CallHero,this.call_hero,this) } onDestroy(){ - oops.message.off(GameEvent.CallFriend,this.call_friend,this) + oops.message.off(GameEvent.CallHero,this.call_hero,this) + oops.message.off(GameEvent.FightReady,this.fight_ready,this) + oops.message.off(GameEvent.Zhaohuan,this.zhao_huan,this) + oops.message.off(GameEvent.MissionEnd,this.clear_heros,this) } start() { @@ -37,45 +39,27 @@ export class MissionHeroCompComp extends CCComp { } fight_ready(){ - // this.heros=[] - // for(let i=0;i(Hero); let scale = 1 let pos:Vec3 = HeroPos[hero_pos].pos; - let fight_pos=1 - - hero.load(pos,scale,uuid,fight_pos,is_master,is_friend); + hero.load(pos,scale,uuid); }