diff --git a/assets/script/game/common/config/GameEvent.ts b/assets/script/game/common/config/GameEvent.ts index f99997ca..601cc955 100644 --- a/assets/script/game/common/config/GameEvent.ts +++ b/assets/script/game/common/config/GameEvent.ts @@ -74,6 +74,7 @@ export enum GameEvent { UpdateMissionGet = "UpdateMissionGet", GlobalAttrChange = "GlobalAttrChange", CoinAdd = "CoinAdd", + ShowSmallTip = "ShowSmallTip", CardPoolUpgrade = "CardPoolUpgrade", TriggerSkill = "TriggerSkill", // 瞬间触发施法事件 RemoveSkillBox = "RemoveSkillBox", // 技能盒销毁事件 diff --git a/assets/script/game/map/CardComp.ts b/assets/script/game/map/CardComp.ts index ffd9f436..b1adb252 100644 --- a/assets/script/game/map/CardComp.ts +++ b/assets/script/game/map/CardComp.ts @@ -310,7 +310,7 @@ export class CardComp extends CCComp { // 使用统一经济管理入口消费金币 const success = MissionEconomy.spendCoin(cardCost); if (!success) { - oops.gui.toast(`金币不足,召唤需要${cardCost}`); + oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin"); this.playReboundAnim(); mLogger.log(this.debugMode, "CardComp", "use card coin not enough", { uuid: this.cardData.uuid, diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 77fe2a82..54a46013 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -292,6 +292,7 @@ export class MissionCardComp extends CCComp { oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this); oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this); oops.message.on(GameEvent.CardPoolUpgrade, this.onCardPoolUpgrade, this); + oops.message.on(GameEvent.ShowSmallTip, this.onShowSmallTip, this); /** 按钮触控事件:抽卡与卡池升级 */ this.cards_chou?.on(NodeEventType.TOUCH_START, this.onDrawTouchStart, this); @@ -358,12 +359,48 @@ export class MissionCardComp extends CCComp { }); // 提示卡池升级 - oops.gui.toast(`卡池已升至${this.poolLv}级`); + this.showSmallTip("pool_upgrade"); // 更新UI this.updatePoolLvUI(); } + private onShowSmallTip(event: string, args: any) { + const type = args as string; + this.showSmallTip(type as any); + } + + public showSmallTip(type: "refresh_coin" | "pool_upgrade" | "buy_coin" | "hero_full") { + let targetNode: Node | null = null; + switch (type) { + case "refresh_coin": + targetNode = this.cards_chou; + break; + case "pool_upgrade": + targetNode = this.pool_lv_node; + break; + case "buy_coin": + targetNode = this.coins_node; + break; + case "hero_full": + targetNode = this.hero_num_node; + break; + } + if (targetNode && targetNode.isValid) { + const tipNode = targetNode.getChildByName("smalltip"); + if (tipNode) { + tipNode.active = true; + Tween.stopAllByTarget(tipNode); + tween(tipNode) + .delay(2) + .call(() => { + if (tipNode && tipNode.isValid) tipNode.active = false; + }) + .start(); + } + } + } + private onPhasePrepareStart() { this.updateHeroNumUI(true, true); } @@ -469,6 +506,7 @@ export class MissionCardComp extends CCComp { oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this); oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this); oops.message.off(GameEvent.CardPoolUpgrade, this.onCardPoolUpgrade, this); + oops.message.off(GameEvent.ShowSmallTip, this.onShowSmallTip, this); if (this.cards_chou && this.cards_chou.isValid) { this.cards_chou.off(NodeEventType.TOUCH_START, this.onDrawTouchStart, this); this.cards_chou.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this); @@ -558,7 +596,7 @@ export class MissionCardComp extends CCComp { } payload.cancel = true; payload.reason = "hero_limit"; - oops.gui.toast(`英雄已满 (${current}/${heroMax})`); + this.showSmallTip("hero_full"); this.playHeroNumDeniedAnim(); } } @@ -678,7 +716,7 @@ export class MissionCardComp extends CCComp { const cost = MissionEconomy.getRefreshCost(this.refreshCost); const success = MissionEconomy.executeRefresh(this.refreshCost); if (!success) { - oops.gui.toast(`金币不足,刷新需要${cost}`); + this.showSmallTip("refresh_coin"); return; } const cards = this.buildSkillDrawCards(); @@ -735,7 +773,7 @@ export class MissionCardComp extends CCComp { const cost = MissionEconomy.getRefreshCost(this.refreshCost); const success = MissionEconomy.executeRefresh(this.refreshCost); if (!success) { - oops.gui.toast(`金币不足,刷新需要${cost}`); + this.showSmallTip("refresh_coin"); this.updateCoinAndCostUI(); mLogger.log(this.debugMode, "MissionCardComp", "draw coin not enough", { currentCoin: MissionEconomy.getCoin(), diff --git a/assets/script/game/map/SCardComp.ts b/assets/script/game/map/SCardComp.ts index c4fbbd73..7a09be19 100644 --- a/assets/script/game/map/SCardComp.ts +++ b/assets/script/game/map/SCardComp.ts @@ -96,7 +96,7 @@ export class SCardComp extends CCComp { const success = MissionEconomy.spendCoin(cardCost); if (!success) { - oops.gui.toast(`金币不足,需要${cardCost}`); + oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin"); this.playReboundAnim(); return null; }