refactor: 重构关卡经济与战斗流程
1. 移除战斗阶段限制,允许玩家在战斗中操作卡牌 2. 新增波次间5秒自动倒计时机制 3. 将固定波次金币奖励改为怪物死亡掉落 4. 重构卡牌面板逻辑,统一抽卡按钮状态判断 5. 清理冗余的战斗阶段状态变量与相关代码
This commit is contained in:
@@ -135,9 +135,6 @@ export class MissionCardComp extends CCComp {
|
||||
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
/** 当前是否为战斗阶段 */
|
||||
private isBattlePhase: boolean = false;
|
||||
|
||||
/** 四个槽位对应的 CardComp 控制器缓存(有序数组) */
|
||||
private cardComps: CardComp[] = [];
|
||||
/** 技能卡槽控制器缓存 */
|
||||
@@ -203,7 +200,6 @@ export class MissionCardComp extends CCComp {
|
||||
* 6. 执行首次抽卡并分发到 4 个槽位。
|
||||
*/
|
||||
onMissionStart() {
|
||||
this.isBattlePhase = false;
|
||||
this.enterPreparePhase();
|
||||
this.poolLv = CARD_POOL_INIT_LEVEL;
|
||||
const missionData = this.getMissionData();
|
||||
@@ -326,11 +322,9 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
/** 战斗开始:不收起面板,不再强制清空卡牌 */
|
||||
/** 战斗开始:保留卡牌面板,允许玩家在战斗阶段继续抽卡和召唤英雄 */
|
||||
private onFightStart() {
|
||||
this.isBattlePhase = true;
|
||||
this.enterBattlePhase();
|
||||
this.clearAllCards();
|
||||
|
||||
// 第一次进入战斗阶段,关闭guide4
|
||||
if (!smc.finish_guides.includes(4)) {
|
||||
@@ -392,10 +386,10 @@ export class MissionCardComp extends CCComp {
|
||||
if (tipNode) {
|
||||
tipNode.active = true;
|
||||
Tween.stopAllByTarget(tipNode);
|
||||
|
||||
|
||||
// 设置初始状态:缩放为 0
|
||||
tipNode.setScale(new Vec3(0, 0, 1));
|
||||
|
||||
|
||||
tween(tipNode)
|
||||
// 1. 弹出动画(微放大再回弹)
|
||||
.to(0.15, { scale: new Vec3(1.1, 1.1, 1) }, { easing: 'quadOut' })
|
||||
@@ -418,7 +412,6 @@ export class MissionCardComp extends CCComp {
|
||||
|
||||
/** 新一波:展开面板 → 刷新费用 UI → 重新抽卡分发 */
|
||||
private onNewWave() {
|
||||
this.isBattlePhase = false;
|
||||
this.enterPreparePhase();
|
||||
this.updateCoinAndCostUI();
|
||||
this.layoutCardSlots();
|
||||
@@ -495,13 +488,13 @@ export class MissionCardComp extends CCComp {
|
||||
// 如果我们把它包在 `if (!smc.finish_guides.includes(2))` 里,
|
||||
// 当玩家点击 guide2 把它关掉时(finish_guides 存入了 2),
|
||||
// 再点技能卡触发这个方法,外层 if 就会进不去,guide3 就永远弹不出来了!
|
||||
|
||||
|
||||
// 修复:独立判断 guide2 的关闭 和 guide3 的开启
|
||||
if (!smc.finish_guides.includes(2)) {
|
||||
smc.finish_guides.push(2);
|
||||
oops.gui.remove(UIID.Guide2);
|
||||
}
|
||||
|
||||
|
||||
if (!smc.finish_guides.includes(3)) {
|
||||
oops.gui.open(UIID.Guide3);
|
||||
}
|
||||
@@ -563,7 +556,7 @@ export class MissionCardComp extends CCComp {
|
||||
smc.finish_guides.push(3);
|
||||
oops.gui.remove(UIID.Guide3);
|
||||
}
|
||||
|
||||
|
||||
if (!smc.finish_guides.includes(4)) {
|
||||
oops.gui.open(UIID.Guide4);
|
||||
}
|
||||
@@ -589,12 +582,7 @@ export class MissionCardComp extends CCComp {
|
||||
const payload = args ?? event;
|
||||
if (!payload) return;
|
||||
|
||||
if (this.isBattlePhase) {
|
||||
payload.cancel = true;
|
||||
payload.reason = "battle_phase";
|
||||
oops.gui.toast("战斗阶段无法召唤英雄");
|
||||
return;
|
||||
}
|
||||
// 战斗阶段也允许召唤英雄(无需额外费用),仅校验英雄数量上限
|
||||
|
||||
const current = this.getAliveHeroCount();
|
||||
this.syncMissionHeroData(current);
|
||||
@@ -781,10 +769,7 @@ export class MissionCardComp extends CCComp {
|
||||
* 3. 重新布局槽位 → 从卡池构建 4 张卡 → 分发到槽位。
|
||||
*/
|
||||
private onClickDraw() {
|
||||
if (this.isBattlePhase) {
|
||||
oops.gui.toast("战斗阶段无法抽卡");
|
||||
return;
|
||||
}
|
||||
// 战斗阶段和倒计时阶段均允许刷新抽卡
|
||||
const cost = MissionEconomy.getRefreshCost(this.refreshCost);
|
||||
const success = MissionEconomy.executeRefresh(this.refreshCost);
|
||||
if (!success) {
|
||||
@@ -868,22 +853,13 @@ export class MissionCardComp extends CCComp {
|
||||
private enterBattlePhase() {
|
||||
if (!this.cards_node || !this.cards_node.isValid) return;
|
||||
this.initCardsPanelPos();
|
||||
// 战斗阶段允许抽卡:nobg 按"金币是否足够"判断,而非强制置灰
|
||||
if (this.cards_chou && this.cards_chou.isValid) {
|
||||
const nobg = this.cards_chou.getChildByName("nobg");
|
||||
if (nobg) {
|
||||
nobg.active = true;
|
||||
nobg.active = !this.canDrawCards();
|
||||
}
|
||||
}
|
||||
// 战斗阶段不再隐藏抽卡面板
|
||||
// Tween.stopAllByTarget(this.cards_node);
|
||||
// tween(this.cards_node)
|
||||
// .to(this.cardsPanelMoveDuration, { scale: this.cardsHideScale })
|
||||
// .call(() => {
|
||||
// if (this.cards_node && this.cards_node.isValid) {
|
||||
// this.cards_node.active = false;
|
||||
// }
|
||||
// })
|
||||
// .start();
|
||||
}
|
||||
|
||||
/** 构建本次抽卡结果,保证最终可分发3条数据 */
|
||||
@@ -924,7 +900,7 @@ export class MissionCardComp extends CCComp {
|
||||
unique: true
|
||||
});
|
||||
if (fallback.length === 0) break;
|
||||
|
||||
|
||||
// 如果池子数量不足,只能被迫允许重复,但尽量拿没被抽到的
|
||||
const fPick = fallback.find(c => !filled.some(fc => fc.uuid === c.uuid));
|
||||
if (fPick) {
|
||||
@@ -1046,7 +1022,7 @@ export class MissionCardComp extends CCComp {
|
||||
label.string = `lv.${lv}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const nextNode = this.pool_lv_node.getChildByName("next");
|
||||
if (nextNode) {
|
||||
const nextLabel = nextNode.getComponent(Label);
|
||||
@@ -1098,10 +1074,11 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
|
||||
private updateDrawCostUI() {
|
||||
// 战斗阶段也允许抽卡,nobg 统一按"金币是否足够"判断
|
||||
if (this.cards_chou) {
|
||||
const nobg = this.cards_chou.getChildByName("nobg");
|
||||
if (nobg) {
|
||||
nobg.active = this.isBattlePhase ? true : !this.canDrawCards();
|
||||
nobg.active = !this.canDrawCards();
|
||||
}
|
||||
const coinNode = this.cards_chou.getChildByName("coin");
|
||||
const numLabel = coinNode?.getChildByName("num")?.getComponent(Label);
|
||||
|
||||
Reference in New Issue
Block a user