feat(ui): 将卡牌槽位从4个调整为3个并更新布局

- 隐藏第四个卡牌槽位,将抽卡逻辑从4张改为3张
- 调整卡牌预制体中的位置和尺寸以适配新布局
- 更新角色控制器UI的宽度和间距设置
- 修改卡牌放大时的位置判定阈值和高度
This commit is contained in:
panw
2026-04-24 10:05:16 +08:00
parent 5dfc790412
commit 051342a9c4
4 changed files with 535 additions and 654 deletions

View File

@@ -520,7 +520,10 @@ export class MissionCardComp extends CCComp {
/** 将四个卡槽节点映射为 CardComp形成固定顺序控制数组 */
private cacheCardComps() {
const nodes = [this.card1, this.card2, this.card3, this.card4];
if (this.card4) {
this.card4.active = false;
}
const nodes = [this.card1, this.card2, this.card3];
this.cardComps = nodes
.map(node => node?.getComponent(CardComp))
.filter((comp): comp is CardComp => !!comp);
@@ -641,7 +644,7 @@ export class MissionCardComp extends CCComp {
});
}
/** 构建本次抽卡结果,保证最终可分发4条数据 */
/** 构建本次抽卡结果,保证最终可分发3条数据 */
private buildDrawCards(): CardConfig[] {
let targetType: CardType | CardType[] | undefined = undefined;
if (this.isBattlePhase) {
@@ -651,11 +654,11 @@ export class MissionCardComp extends CCComp {
}
const cards = getCardsByLv(this.poolLv, targetType);
/** 正常情况下直接取前4 */
if (cards.length >= 4) return cards.slice(0, 4);
/** 兜底:当返回不足4张时循环补齐,保证分发不缺位 */
/** 正常情况下直接取前3 */
if (cards.length >= 3) return cards.slice(0, 3);
/** 兜底:当返回不足3张时循环补齐,保证分发不缺位 */
const filled = [...cards];
while (filled.length < 4) {
while (filled.length < 3) {
const fallback = getCardsByLv(this.poolLv, targetType);
if (fallback.length === 0) break;
filled.push(fallback[filled.length % fallback.length]);
@@ -665,14 +668,14 @@ export class MissionCardComp extends CCComp {
private tryRefreshHeroCards(heroType?: HType, targetPoolLv?: number): boolean {
const cards = drawCardsByRule(this.poolLv, {
count: 4,
count: 3,
type: CardType.Hero,
heroType,
targetPoolLv
});
if (cards.length <= 0) return false;
this.layoutCardSlots();
this.dispatchCardsToSlots(cards.slice(0, 4));
this.dispatchCardsToSlots(cards.slice(0, 3));
return true;
}
@@ -708,15 +711,12 @@ export class MissionCardComp extends CCComp {
private layoutCardSlots() {
const count = this.cardComps.length;
if (count === 0) return;
const startX = -((count - 1) * this.cardWidth) / 2;
for (let i = 0; i < count; i++) {
const x = startX + i * this.cardWidth;
this.cardComps[i].setSlotPosition(x);
this.cardComps[i].setSlotPosition(this.cardsPos[i]);
}
mLogger.log(this.debugMode, "MissionCardComp", "layout card slots", {
count,
cardWidth: this.cardWidth,
startX
cardWidth: this.cardWidth
});
}