feat: 为卡牌组件添加拖拽使用动画并增强日志

- 为 CardComp 添加拖拽使用交互:上拉超过阈值触发使用,否则回弹
- 增加卡牌刷新、回弹、使用消失的 Tween 动画
- 在 MissionCardComp 和 CardComp 的关键节点添加调试日志
- 修复升级按钮在达到最大等级后隐藏升级提示的问题
- 优化卡牌使用和清槽时的动画与状态重置逻辑
This commit is contained in:
walkpan
2026-03-14 09:42:08 +08:00
parent d0e824e93b
commit b32cea1c00
2 changed files with 153 additions and 8 deletions

View File

@@ -40,6 +40,10 @@ export class MissionCardComp extends CCComp {
this.bindEvents();
this.cacheCardComps();
this.onMissionStart();
mLogger.log(this.debugMode, "MissionCardComp", "onLoad init", {
slots: this.cardComps.length,
poolLv: this.poolLv
});
}
onDestroy() {
@@ -53,8 +57,14 @@ export class MissionCardComp extends CCComp {
onMissionStart() {
this.poolLv = CARD_POOL_INIT_LEVEL;
this.clearAllCards();
if (this.cards_up) {
this.cards_up.active = true;
}
this.updatePoolLvUI();
this.node.active = true;
mLogger.log(this.debugMode, "MissionCardComp", "mission start", {
poolLv: this.poolLv
});
}
/** 任务结束时清空4槽并隐藏面板 */
@@ -100,14 +110,23 @@ export class MissionCardComp extends CCComp {
/** 抽卡按钮每次固定抽4张然后顺序分发给4个单卡脚本 */
private onClickDraw() {
mLogger.log(this.debugMode, "MissionCardComp", "click draw", {
poolLv: this.poolLv
});
const cards = this.buildDrawCards();
this.dispatchCardsToSlots(cards);
}
/** 升级按钮:仅提升卡池等级,卡槽是否更新由下一次抽卡触发 */
private onClickUpgrade() {
if (this.poolLv >= CARD_POOL_MAX_LEVEL) return;
if (this.poolLv >= CARD_POOL_MAX_LEVEL) {
mLogger.log(this.debugMode, "MissionCardComp", "pool already max", this.poolLv);
return;
}
this.poolLv += 1;
if (this.poolLv >= CARD_POOL_MAX_LEVEL && this.cards_up) {
this.cards_up.active = false;
}
this.updatePoolLvUI();
mLogger.log(this.debugMode, "MissionCardComp", "pool level up", this.poolLv);
}
@@ -130,7 +149,12 @@ export class MissionCardComp extends CCComp {
/** 全量分发给4槽每个槽位是否接收由 CardComp 自己判断(锁定可跳过) */
private dispatchCardsToSlots(cards: CardConfig[]) {
for (let i = 0; i < this.cardComps.length; i++) {
this.cardComps[i].applyDrawCard(cards[i] ?? null);
const accepted = this.cardComps[i].applyDrawCard(cards[i] ?? null);
mLogger.log(this.debugMode, "MissionCardComp", "dispatch card", {
index: i,
card: cards[i]?.uuid ?? 0,
accepted
});
}
}
@@ -145,6 +169,7 @@ export class MissionCardComp extends CCComp {
const label = this.cards_up.getComponentInChildren(Label);
if (!label) return;
label.string = `卡池Lv.${this.poolLv}`;
mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", this.poolLv);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */