fix(ui): 调整卡牌预制体尺寸并修复开始按钮状态逻辑

- 修正卡牌预制体的局部位置、尺寸模式和内容大小,优化显示效果
- 隐藏预制体中不必要的节点以提升性能
- 重构开始按钮状态控制逻辑,改为根据游戏阶段动态更新按钮的可点击状态
- 移除直接隐藏按钮的代码,确保按钮在准备阶段且未暂停时可点击
This commit is contained in:
panw
2026-04-21 16:57:49 +08:00
parent 73ca2ffbf0
commit 24c32549c0
3 changed files with 694 additions and 499 deletions

View File

@@ -863,7 +863,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0.5, "y": 0,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -995,7 +995,7 @@
}, },
"_type": 0, "_type": 0,
"_fillType": 0, "_fillType": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
@@ -1042,8 +1042,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 164, "width": 156,
"height": 223 "height": 210
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -3243,7 +3243,7 @@
"__id__": 181 "__id__": 181
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 189 "__id__": 189
@@ -8440,7 +8440,7 @@
"__id__": 390 "__id__": 390
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 396 "__id__": 396

File diff suppressed because it is too large Load Diff

View File

@@ -288,6 +288,17 @@ export class MissionComp extends CCComp {
},0.5) },0.5)
} }
/** 更新开始按钮的状态显示 */
private updateStartBtnState() {
if (!this.start_btn || !this.start_btn.isValid) return;
const nobg = this.start_btn.getChildByName("nobg");
if (nobg) {
// 只有在 Prepare 阶段且未暂停时,按钮才可点击,否则激活 nobg显示不可点击状态
const canClick = this.currentPhase === MissionPhase.Prepare && smc.mission.play && !smc.mission.pause;
nobg.active = !canClick;
}
}
/** /**
* 阶段切换核心方法(状态机) * 阶段切换核心方法(状态机)
* 处理状态流转时所需的事件触发和全局标志位修改。 * 处理状态流转时所需的事件触发和全局标志位修改。
@@ -330,7 +341,7 @@ export class MissionComp extends CCComp {
smc.mission.in_fight = false; smc.mission.in_fight = false;
smc.vmdata.mission_data.in_fight = false; smc.vmdata.mission_data.in_fight = false;
smc.mission.stop_spawn_mon = true; smc.mission.stop_spawn_mon = true;
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; // 不隐藏开始按钮,点击事件在 onStartFightBtnClick 内部做了阶段拦截
break; break;
case MissionPhase.Prepare: case MissionPhase.Prepare:
@@ -338,7 +349,7 @@ export class MissionComp extends CCComp {
break; break;
case MissionPhase.PrepareEnd: case MissionPhase.PrepareEnd:
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; // 不隐藏开始按钮
oops.message.dispatchEvent("PhasePrepareEnd"); oops.message.dispatchEvent("PhasePrepareEnd");
break; break;
@@ -366,7 +377,7 @@ export class MissionComp extends CCComp {
smc.mission.in_fight = false; smc.mission.in_fight = false;
smc.vmdata.mission_data.in_fight = false; smc.vmdata.mission_data.in_fight = false;
smc.mission.stop_spawn_mon = true; smc.mission.stop_spawn_mon = true;
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; // 不隐藏开始按钮
break; break;
case MissionPhase.None: case MissionPhase.None:
@@ -376,6 +387,9 @@ export class MissionComp extends CCComp {
if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false; if (this.start_btn && this.start_btn.isValid) this.start_btn.active = false;
break; break;
} }
// 阶段切换后更新按钮状态
this.updateStartBtnState();
} }
/** 自动流转到下一阶段(过渡状态结束时调用) */ /** 自动流转到下一阶段(过渡状态结束时调用) */