From cade854fc7a39e046aed68a3cfadad96104abf15 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 18:05:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B8=B8=E6=88=8F=E4=BA=8B=E4=BB=B6):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=8D=E6=B4=BB=E6=88=90=E5=8A=9F=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E8=8B=B1=E9=9B=84=E6=AD=BB?= =?UTF-8?q?=E4=BA=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在GameEvent枚举中添加ReviveSuccess事件 - 在SingletonModuleComp中添加score字段用于记录分数 - 移除HeroViewComp中无用的战斗结束相关代码 - 优化英雄死亡逻辑,只有主角死亡才触发游戏结束判定 --- assets/script/game/common/SingletonModuleComp.ts | 1 + assets/script/game/common/config/GameEvent.ts | 1 + assets/script/game/hero/HeroViewComp.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 7adbc08a..58b30ff6 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -65,6 +65,7 @@ export class SingletonModuleComp extends ecs.Comp { max_mission:4,//最大关卡 coin:0, time:15*60,//游戏时间 + score:0, }, hero:{ name:'', diff --git a/assets/script/game/common/config/GameEvent.ts b/assets/script/game/common/config/GameEvent.ts index d8543afa..a98d496f 100644 --- a/assets/script/game/common/config/GameEvent.ts +++ b/assets/script/game/common/config/GameEvent.ts @@ -63,4 +63,5 @@ export enum GameEvent { GOLD_UPDATE = "GOLD_UPDATE", DIAMOND_UPDATE = "DIAMOND_UPDATE", MEAT_UPDATE = "MEAT_UPDATE", + ReviveSuccess = "ReviveSuccess", } \ No newline at end of file diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 3551a4ca..a220b614 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -74,7 +74,6 @@ export class HeroViewComp extends CCComp { onLoad() { this.as = this.getComponent(HeroSpine); //console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON) - this.on(GameEvent.FightEnd,this.do_fight_end,this) const collider = this.node.getComponent(BoxCollider2D); this.scheduleOnce(()=>{ if (collider) { @@ -308,9 +307,7 @@ export class HeroViewComp extends CCComp { // 注意:BaseUp 逻辑已移到 HeroAttrSystem.update() // 注意:updateTemporaryBuffsDebuffs 逻辑已移到 HeroAttrSystem.update() - do_fight_end(){ - this.as.do_buff() - } + get isActive() { return this.ent.has(HeroViewComp) && this.node?.isValid; } @@ -418,9 +415,12 @@ export class HeroViewComp extends CCComp { if(this.model.fac === FacSet.HERO){ // 英雄死亡:延迟触发死亡事件 - oops.message.dispatchEvent(GameEvent.HeroDead, { - hero_uuid: this.model.hero_uuid - }); + // 🔥 只有主角死亡才触发游戏结束判定 + if (this.model.is_master) { + oops.message.dispatchEvent(GameEvent.HeroDead, { + hero_uuid: this.model.hero_uuid + }); + } } // 根据阵营触发不同事件 if(this.model.fac === FacSet.MON){