fix(mission): 处理英雄全灭时自动结束战斗并优化UI显示
- 在 MissionComp 中新增 handleHeroWipe 方法,当英雄数量为0且处于战斗状态时自动结束战斗 - 修复 MissionCardComp 中卡池等级UI显示逻辑,简化激活条件判断 - 调整 role_controller.prefab 中多个UI元素的布局参数,优化界面显示效果
This commit is contained in:
@@ -290,11 +290,19 @@ export class MissionComp extends CCComp {
|
||||
if (dt > 0 && this.monsterCountSyncTimer < 0.2) return;
|
||||
this.monsterCountSyncTimer = 0;
|
||||
let monsterCount = 0;
|
||||
let heroCount = 0;
|
||||
ecs.query(this.heroAttrsMatcher).forEach(entity => {
|
||||
const attrs = entity.get(HeroAttrsComp);
|
||||
if (!attrs || attrs.fac !== FacSet.MON || attrs.is_dead) return;
|
||||
monsterCount += 1;
|
||||
if (!attrs || attrs.is_dead) return;
|
||||
if (attrs.fac === FacSet.MON) {
|
||||
monsterCount += 1;
|
||||
return;
|
||||
}
|
||||
if (attrs.fac === FacSet.HERO) {
|
||||
heroCount += 1;
|
||||
}
|
||||
});
|
||||
this.handleHeroWipe(heroCount);
|
||||
smc.vmdata.mission_data.mon_num = monsterCount;
|
||||
const { max, resume } = this.getMonsterThresholds();
|
||||
smc.vmdata.mission_data.mon_max = max;
|
||||
@@ -306,6 +314,15 @@ export class MissionComp extends CCComp {
|
||||
if (monsterCount >= max) smc.mission.stop_spawn_mon = true;
|
||||
}
|
||||
|
||||
private handleHeroWipe(heroCount: number) {
|
||||
if (heroCount > 0) return;
|
||||
if (!smc.mission.play || smc.mission.pause) return;
|
||||
if (!smc.mission.in_fight) return;
|
||||
smc.mission.in_fight = false;
|
||||
smc.vmdata.mission_data.in_fight = false;
|
||||
this.open_Victory(null, true);
|
||||
}
|
||||
|
||||
private cleanComponents() {
|
||||
const heroEntities: ecs.Entity[] = [];
|
||||
ecs.query(this.heroViewMatcher).forEach(entity => {
|
||||
|
||||
Reference in New Issue
Block a user