2 Commits

Author SHA1 Message Date
pan
97ff09669c feat(CardComp): add coin insufficient prompt feature
1. 新增金币不足提示节点配置与显示逻辑
2. 优化等级文本的分隔符为更直观的箭头符号
3. 修复提示节点未默认隐藏的问题
2026-07-21 14:24:46 +08:00
pan
486090682a refactor(map): remove unused NewWave event listener and handler
删除了废弃的 NewWave 事件监听和对应的 onNewWave 处理函数,清理冗余代码。
2026-07-21 14:22:09 +08:00
2 changed files with 29 additions and 12 deletions

View File

@@ -97,6 +97,9 @@ export class CardComp extends CCComp {
ap_node = null!
@property(Node)
hp_node = null!
/** 金币不足提示节点useCard 费用不足时显示 2 秒) */
@property(Node)
no_cion_node = null!
// ======================== 运行时状态 ========================
@@ -147,6 +150,8 @@ export class CardComp extends CCComp {
this.applyEmptyUI();
// call_btn 默认隐藏,仅在点击本卡时显示
this.hideCallBtn();
// 金币不足提示默认隐藏
if (this.no_cion_node) this.no_cion_node.active = false;
}
/** 组件销毁时解绑所有事件,防止残留回调 */
@@ -307,6 +312,8 @@ export class CardComp extends CCComp {
if (!success) {
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
this.playReboundAnim();
// 显示"金币不足"提示节点 2 秒
this.showNoCoinNode();
mLogger.log(this.debugMode, "CardComp", "use card coin not enough", {
uuid: this.cardData.uuid,
type: this.cardData.type,
@@ -754,7 +761,7 @@ export class CardComp extends CCComp {
if (this.lvl_node) {
// 升级卡:显示「当前→升级后」;普通英雄卡:显示当前等级。统一使用默认颜色
if (isUpgradeCard && heroLv > 1) {
this.lvl_node.string = `Lv.${heroLv - 1} Lv.${heroLv}`;
this.lvl_node.string = `Lv.${heroLv - 1} -> Lv.${heroLv}`;
} else {
this.lvl_node.string = `Lv.${heroLv}`;
}
@@ -844,6 +851,26 @@ export class CardComp extends CCComp {
.start();
}
/**
* 显示"金币不足"提示节点2 秒后自动隐藏。
* Why: useCard 金币不足时给玩家明确的视觉反馈。
* 使用 scheduleOnce 与组件生命周期绑定,组件销毁时自动清理。
*/
private showNoCoinNode() {
if (!this.no_cion_node) return;
// 清理上一次的隐藏回调,避免连续触发时被提前关闭
this.unschedule(this.hideNoCoinNode);
this.no_cion_node.active = true;
this.scheduleOnce(this.hideNoCoinNode, 2);
}
/** 隐藏"金币不足"提示节点 */
private hideNoCoinNode() {
if (this.no_cion_node && this.no_cion_node.isValid) {
this.no_cion_node.active = false;
}
}
/**
* 使用消失动画:
* - 节点从当前位置向上移动 120pxX 轴保持当前值不变,不使用 restPosition.x

View File

@@ -262,7 +262,7 @@ export class MissionCardComp extends CCComp {
/**
* 绑定所有事件监听:
* - 节点级事件MissionStart / MissionEnd / NewWave / FightStart
* - 节点级事件MissionStart / MissionEnd / FightStart
* - 全局消息CoinAdd / MasterCalled / HeroDead / UseHeroCard / UseSpecialCard
* - 按钮触控抽卡cards_chou
*/
@@ -270,7 +270,6 @@ export class MissionCardComp extends CCComp {
/** 生命周期事件(节点级) */
this.on(GameEvent.MissionStart, this.onMissionStart, this);
this.on(GameEvent.MissionEnd, this.onMissionEnd, this);
this.on(GameEvent.NewWave, this.onNewWave, this);
this.on(GameEvent.FightStart, this.onFightStart, this);
this.on("PhasePrepareStart", this.onPhasePrepareStart, this);
@@ -372,15 +371,6 @@ export class MissionCardComp extends CCComp {
this.updateHeroNumUI(true, true);
}
/** 新一波:展开面板 → 刷新费用 UI → 重新抽卡分发 */
private onNewWave() {
this.enterPreparePhase();
this.updateCoinAndCostUI();
this.layoutCardSlots();
const cards = this.buildDrawCards();
this.dispatchCardsToSlots(cards);
}
/**
* 技能卡入场动画:每个卡槽从场景基准位置下方 80px 处升起,
* 终止位置 = 场景编辑器位置(保持初始不做位移的约束),