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

View File

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

View File

@@ -290,11 +290,19 @@ export class MissionComp extends CCComp {
if (dt > 0 && this.monsterCountSyncTimer < 0.2) return; if (dt > 0 && this.monsterCountSyncTimer < 0.2) return;
this.monsterCountSyncTimer = 0; this.monsterCountSyncTimer = 0;
let monsterCount = 0; let monsterCount = 0;
let heroCount = 0;
ecs.query(this.heroAttrsMatcher).forEach(entity => { ecs.query(this.heroAttrsMatcher).forEach(entity => {
const attrs = entity.get(HeroAttrsComp); const attrs = entity.get(HeroAttrsComp);
if (!attrs || attrs.fac !== FacSet.MON || attrs.is_dead) return; if (!attrs || attrs.is_dead) return;
monsterCount += 1; 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; smc.vmdata.mission_data.mon_num = monsterCount;
const { max, resume } = this.getMonsterThresholds(); const { max, resume } = this.getMonsterThresholds();
smc.vmdata.mission_data.mon_max = max; 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; 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() { private cleanComponents() {
const heroEntities: ecs.Entity[] = []; const heroEntities: ecs.Entity[] = [];
ecs.query(this.heroViewMatcher).forEach(entity => { ecs.query(this.heroViewMatcher).forEach(entity => {