fix(mission): 处理英雄全灭时自动结束战斗并优化UI显示

- 在 MissionComp 中新增 handleHeroWipe 方法,当英雄数量为0且处于战斗状态时自动结束战斗
- 修复 MissionCardComp 中卡池等级UI显示逻辑,简化激活条件判断
- 调整 role_controller.prefab 中多个UI元素的布局参数,优化界面显示效果
This commit is contained in:
walkpan
2026-03-28 18:39:00 +08:00
parent ddce1208ee
commit 99ee713a1f
3 changed files with 68 additions and 44 deletions

View File

@@ -2962,7 +2962,7 @@
"__prefab": {
"__id__": 125
},
"_resizeMode": 1,
"_resizeMode": 0,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
@@ -2997,6 +2997,8 @@
"__id__": 0
},
"fileId": "33rSVysAVB1LO2v7wC2zZ1",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -3924,7 +3926,7 @@
"__prefab": {
"__id__": 167
},
"_resizeMode": 1,
"_resizeMode": 0,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
@@ -3943,7 +3945,7 @@
"_constraint": 0,
"_constraintNum": 2,
"_affectedByScale": false,
"_isAlign": false,
"_isAlign": true,
"_id": ""
},
{
@@ -3959,6 +3961,8 @@
"__id__": 0
},
"fileId": "50nlTzRABGJ4vZYBkdXijK",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -4156,6 +4160,8 @@
"__id__": 0
},
"fileId": "ebDo8RYmhKJoLQcsDOvm6d",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -4191,7 +4197,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -44.229,
"x": -70,
"y": 0,
"z": 0
},
@@ -4741,7 +4747,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 10,
"x": -47.013,
"y": 0,
"z": 0
},
@@ -4787,7 +4793,7 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_id": ""
@@ -4819,7 +4825,7 @@
"a": 255
},
"_string": "{{0}}/{{1}}",
"_horizontalAlign": 1,
"_horizontalAlign": 0,
"_verticalAlign": 1,
"_actualFontSize": 25,
"_fontSize": 25,
@@ -5180,6 +5186,8 @@
"__id__": 0
},
"fileId": "35dr0lJV9CO5Ld8TLk7eCZ",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -5205,7 +5213,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -71.736,
"x": -70.3,
"y": 0,
"z": 0
},
@@ -5317,6 +5325,8 @@
"__id__": 0
},
"fileId": "e7dPNasr5IyqES0tbwxJX3",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -5345,7 +5355,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -49.32,
"x": -47.013,
"y": 0,
"z": 0
},
@@ -5501,6 +5511,8 @@
"__id__": 0
},
"fileId": "65zRY1wpZPNLTXws9hsdcE",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{

View File

@@ -428,7 +428,7 @@ export class MissionCardComp extends CCComp {
}
/** 更新升级按钮上的等级文案,反馈当前卡池层级 */
private updatePoolLvUI() {
if (!this.cards_up) return;
if (this.cards_up) {
const nobg = this.cards_up.getChildByName("nobg");
if (nobg) {
nobg.active = !this.canUpPool();
@@ -444,27 +444,22 @@ export class MissionCardComp extends CCComp {
label.string = `${this.getUpgradeCost(this.poolLv)}`;
}
}
}
if (this.pool_lv_node) {
let hasMatchedNode = false;
const children = this.pool_lv_node.children;
for (let i = 0; i < children.length; i++) {
const node = children[i];
const lvText = node.name.match(/\d+/)?.[0];
const lv = lvText ? Number(lvText) : (i + 1);
const active = lv === this.poolLv;
node.active = active;
if (active) {
hasMatchedNode = true;
}
}
if (!hasMatchedNode) {
for (let i = 1; i <= CARD_POOL_MAX_LEVEL; i++) {
const n = this.pool_lv_node.getChildByName(`lv${i}`);
if (n) {
n.active = i === this.poolLv;
}
}
}
this.pool_lv_node.active = true;
const lv = Math.max(CARD_POOL_INIT_LEVEL, Math.min(CARD_POOL_MAX_LEVEL, Math.floor(this.poolLv)));
const lv1 = this.pool_lv_node.getChildByName("lv1");
const lv2 = this.pool_lv_node.getChildByName("lv2");
const lv3 = this.pool_lv_node.getChildByName("lv3");
const lv4 = this.pool_lv_node.getChildByName("lv4");
const lv5 = this.pool_lv_node.getChildByName("lv5");
const lv6 = this.pool_lv_node.getChildByName("lv6");
if (lv1) lv1.active = lv >= 1;
if (lv2) lv2.active = lv >= 2;
if (lv3) lv3.active = lv >= 3;
if (lv4) lv4.active = lv >= 4;
if (lv5) lv5.active = lv >= 5;
if (lv6) lv6.active = lv >= 6;
}
mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", {
poolLv: this.poolLv,

View File

@@ -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;
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 => {