diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 5fead161..21a3b780 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -125,7 +125,7 @@ export class MissionCardComp extends CCComp { skill_refresh: Node = null! /**技能广告刷新按钮节点 */ @property(Node) - skill_ad_refresh: Node = null! + skill_ad_refresh: Node = null! /**可用刷新数显示节点 */ @property(Node) skill_refresh_num_node: Node = null! @@ -230,7 +230,7 @@ export class MissionCardComp extends CCComp { } const cards = this.buildDrawCards(); this.dispatchCardsToSlots(cards); - + const wave = this.getCurrentWave(); if ([1, 5, 10, 15, 20].includes(wave)) { this.showSkillCardPopup(); @@ -295,7 +295,7 @@ export class MissionCardComp extends CCComp { this.cards_chou?.on(NodeEventType.TOUCH_START, this.onDrawTouchStart, this); this.cards_chou?.on(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this); this.cards_chou?.on(NodeEventType.TOUCH_CANCEL, this.onDrawTouchCancel, this); - + /** 技能卡刷新按钮 */ this.skill_refresh?.on(NodeEventType.TOUCH_START, this.onSkillDrawTouchStart, this); this.skill_refresh?.on(NodeEventType.TOUCH_END, this.onSkillDrawTouchEnd, this); @@ -375,11 +375,41 @@ export class MissionCardComp extends CCComp { } } + /** + * 技能卡入场动画:每个卡槽从场景基准位置下方 80px 处升起, + * 终止位置 = 场景编辑器位置(保持初始不做位移的约束), + * 多张依次错开 staggerDelay 形成"依次飞入"效果。 + */ + private readonly skillEnterOffsetY: number = -80; + private readonly skillEnterDuration: number = 0.25; + private readonly skillEnterStagger: number = 0.08; + + private playSkillCardEnterAnim() { + if (!this.skillCardComps || this.skillCardComps.length === 0) return; + for (let i = 0; i < this.skillCardComps.length; i++) { + const comp = this.skillCardComps[i]; + if (!comp) continue; + const node = comp.node; + if (!node || !node.isValid) continue; + // 缓存场景编辑器位置作为动画终止点(初始不做位移) + const basePos = node.getPosition(); + // 起始位置 = 基准位置下移 80px + node.setPosition(basePos.x, basePos.y + this.skillEnterOffsetY, basePos.z); + Tween.stopAllByTarget(node); + tween(node) + .delay(i * this.skillEnterStagger) + .to(this.skillEnterDuration, { position: basePos }, { easing: 'quadOut' }) + .start(); + } + } + private showSkillCardPopup() { if (!this.skill_card_node) return; this.skill_card_node.active = true; + // 先分发卡牌数据(让卡面内容就绪),再做入场动画 const cards = this.buildSkillDrawCards(); this.dispatchCardsToSkillSlots(cards); + this.playSkillCardEnterAnim(); } private dispatchCardsToSkillSlots(cards: CardConfig[]) { @@ -578,7 +608,7 @@ export class MissionCardComp extends CCComp { private onDrawTouchCancel() { this.playButtonResetAnim(this.cards_chou); } - + // ======================== 技能抽卡按钮回调 ======================== private onSkillDrawTouchStart() { this.playButtonPressAnim(this.skill_refresh); @@ -638,7 +668,7 @@ export class MissionCardComp extends CCComp { this.cardComps = nodes .map(node => node?.getComponent(CardComp)) .filter((comp): comp is CardComp => !!comp); - + const skillNodes = [this.skill_card1, this.skill_card2, this.skill_card3]; this.skillCardComps = skillNodes .map(node => node?.getComponent(CardComp)) @@ -954,7 +984,7 @@ export class MissionCardComp extends CCComp { numLabel.string = `${MissionEconomy.getRefreshCost(this.refreshCost)}`; } } - + if (this.skill_refresh) { const nobg = this.skill_refresh.getChildByName("nobg"); if (nobg) {