diff --git a/assets/resources/gui/role_controller.prefab b/assets/resources/gui/role_controller.prefab index c3667501..7b7ec2a8 100644 --- a/assets/resources/gui/role_controller.prefab +++ b/assets/resources/gui/role_controller.prefab @@ -8635,7 +8635,7 @@ "node": { "__id__": 342 }, - "_enabled": true, + "_enabled": false, "__prefab": { "__id__": 380 }, diff --git a/assets/script/game/map/CardComp.ts b/assets/script/game/map/CardComp.ts index d78f0447..657e2489 100644 --- a/assets/script/game/map/CardComp.ts +++ b/assets/script/game/map/CardComp.ts @@ -159,6 +159,14 @@ export class CardComp extends CCComp { return this.isLocked; } + setSlotPosition(x: number) { + const current = this.node.position; + this.restPosition = new Vec3(x, current.y, current.z); + if (!this.isDragging && !this.isUsing) { + this.node.setPosition(this.restPosition); + } + } + /** 系统清槽:用于任务开始/结束等强制重置场景 */ clearBySystem() { Tween.stopAllByTarget(this.node); diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 35ce7139..34f11030 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -14,6 +14,7 @@ const { ccclass, property } = _decorator; @ecs.register('MissionCard', false) export class MissionCardComp extends CCComp { private debugMode: boolean = true; + private readonly cardWidth: number = 175; /** 四个插卡槽位(固定顺序分发:1~4) */ @property(Node) card1:Node = null! @@ -39,6 +40,7 @@ export class MissionCardComp extends CCComp { /** 绑定事件 -> 缓存子控制器 -> 初始化UI状态 */ this.bindEvents(); this.cacheCardComps(); + this.layoutCardSlots(); this.onMissionStart(); mLogger.log(this.debugMode, "MissionCardComp", "onLoad init", { slots: this.cardComps.length, @@ -56,6 +58,7 @@ export class MissionCardComp extends CCComp { /** 任务开始时:重置卡池等级、清空4槽、显示面板 */ onMissionStart() { this.poolLv = CARD_POOL_INIT_LEVEL; + this.layoutCardSlots(); this.clearAllCards(); if (this.cards_up) { this.cards_up.active = true; @@ -113,6 +116,7 @@ export class MissionCardComp extends CCComp { mLogger.log(this.debugMode, "MissionCardComp", "click draw", { poolLv: this.poolLv }); + this.layoutCardSlots(); const cards = this.buildDrawCards(); this.dispatchCardsToSlots(cards); } @@ -163,6 +167,21 @@ export class MissionCardComp extends CCComp { this.cardComps.forEach(comp => comp.clearBySystem()); } + 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); + } + mLogger.log(this.debugMode, "MissionCardComp", "layout card slots", { + count, + cardWidth: this.cardWidth, + startX + }); + } + /** 更新升级按钮上的等级文案,反馈当前卡池层级 */ private updatePoolLvUI() { if (!this.cards_up) return;