feat(游戏事件): 添加复活成功事件并优化英雄死亡逻辑

- 在GameEvent枚举中添加ReviveSuccess事件
- 在SingletonModuleComp中添加score字段用于记录分数
- 移除HeroViewComp中无用的战斗结束相关代码
- 优化英雄死亡逻辑,只有主角死亡才触发游戏结束判定
This commit is contained in:
walkpan
2026-01-03 18:05:32 +08:00
parent 08c153ee5d
commit cade854fc7
3 changed files with 9 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ export class SingletonModuleComp extends ecs.Comp {
max_mission:4,//最大关卡
coin:0,
time:15*60,//游戏时间
score:0,
},
hero:{
name:'',

View File

@@ -63,4 +63,5 @@ export enum GameEvent {
GOLD_UPDATE = "GOLD_UPDATE",
DIAMOND_UPDATE = "DIAMOND_UPDATE",
MEAT_UPDATE = "MEAT_UPDATE",
ReviveSuccess = "ReviveSuccess",
}

View File

@@ -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,10 +415,13 @@ export class HeroViewComp extends CCComp {
if(this.model.fac === FacSet.HERO){
// 英雄死亡:延迟触发死亡事件
// 🔥 只有主角死亡才触发游戏结束判定
if (this.model.is_master) {
oops.message.dispatchEvent(GameEvent.HeroDead, {
hero_uuid: this.model.hero_uuid
});
}
}
// 根据阵营触发不同事件
if(this.model.fac === FacSet.MON){
oops.message.dispatchEvent(GameEvent.MonDead, {