refactor(map): 优化槽位检测逻辑并新增满槽提示
1. 为MissEquipComp和MissSkillsComp新增静态实例缓存和isFull方法,避免强引用查询 2. 修复槽位坐标的空格格式问题 3. 扩展showSmallTip的参数类型,新增多种面板满槽提示场景 4. 在英雄、装备、技能面板开启逻辑中添加满槽校验和对应提示
This commit is contained in:
@@ -47,6 +47,8 @@ import { CHeroComp } from "./CHeroComp";
|
||||
import { EquipListComp } from "./EquipListComp";
|
||||
import { HeroBoxComp } from "./HeroBoxComp";
|
||||
import { SCardComp } from "./SCardComp";
|
||||
import { MissEquipComp } from "./MissEquipComp";
|
||||
import { MissSkillsComp } from "./MissSkillsComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
@@ -474,9 +476,12 @@ export class MissionCardComp extends CCComp {
|
||||
/**
|
||||
* 在目标节点上弹出 smalltip 气泡(缩放动画)。
|
||||
* @param type 提示类型(决定挂载到哪个节点)
|
||||
* - refresh_coin / buy_coin / hero_full:挂在抽卡按钮 / 金币节点 / 英雄数量节点
|
||||
* - panel_hero_full / panel_equip_full / panel_skill_full / panel_shop_full:
|
||||
* 挂在 showHeros / showEquips / showSkills / showShop 按钮节点(按钮下需预置 smalltip 子节点)
|
||||
* @param text 可选:覆盖气泡文字(默认读 prefab 中配置的文本)
|
||||
*/
|
||||
public showSmallTip(type: "refresh_coin" | "buy_coin" | "hero_full", text?: string) {
|
||||
public showSmallTip(type: "refresh_coin" | "buy_coin" | "hero_full" | "panel_hero_full" | "panel_equip_full" | "panel_skill_full" | "panel_shop_full", text?: string) {
|
||||
let targetNode: Node | null = null;
|
||||
switch (type) {
|
||||
case "refresh_coin":
|
||||
@@ -488,6 +493,18 @@ export class MissionCardComp extends CCComp {
|
||||
case "hero_full":
|
||||
targetNode = this.hero_num_node;
|
||||
break;
|
||||
case "panel_hero_full":
|
||||
targetNode = this.showHeros;
|
||||
break;
|
||||
case "panel_equip_full":
|
||||
targetNode = this.showEquips;
|
||||
break;
|
||||
case "panel_skill_full":
|
||||
targetNode = this.showSkills;
|
||||
break;
|
||||
case "panel_shop_full":
|
||||
targetNode = this.showShop;
|
||||
break;
|
||||
}
|
||||
if (targetNode && targetNode.isValid) {
|
||||
const tipNode = targetNode.getChildByName("smalltip");
|
||||
@@ -529,6 +546,11 @@ export class MissionCardComp extends CCComp {
|
||||
private onShowSkillsClick() {
|
||||
oops.audio.playEffect("music/button");
|
||||
if (this.isOverlayPanelShown(2)) return;
|
||||
// 技能槽位已满:气泡提示并中止,不再展开三选一,也不扣开启费用
|
||||
if (MissSkillsComp.isFull()) {
|
||||
this.showSmallTip("panel_skill_full", "技能槽已满");
|
||||
return;
|
||||
}
|
||||
// 开启技能面板需支付金币,金币不足则提示并中止
|
||||
if (!this.tryPayPanelOpenCost(2)) return;
|
||||
this.slideToPanel(2);
|
||||
@@ -1037,6 +1059,11 @@ export class MissionCardComp extends CCComp {
|
||||
oops.audio.playEffect("music/button");
|
||||
// 已展开则不重复开启(不重复扣费)
|
||||
if (this.isCardPanelShown) return;
|
||||
// 英雄槽位已满:气泡提示并中止,不再展开三选一,也不扣开启费用
|
||||
if (this.getAliveHeroCount() >= this.getMissionHeroMaxNum()) {
|
||||
this.showSmallTip("panel_hero_full", "英雄槽已满");
|
||||
return;
|
||||
}
|
||||
// 开启英雄抽卡面板需支付金币,金币不足则提示并中止
|
||||
if (!this.tryPayPanelOpenCost(0)) return;
|
||||
// 收起装备/技能/药品覆盖面板
|
||||
@@ -1218,6 +1245,11 @@ export class MissionCardComp extends CCComp {
|
||||
private onShowEquipsClick() {
|
||||
oops.audio.playEffect("music/button");
|
||||
if (this.isOverlayPanelShown(1)) return;
|
||||
// 装备槽位已满:气泡提示并中止,不再展开三选一,也不扣开启费用
|
||||
if (MissEquipComp.isFull()) {
|
||||
this.showSmallTip("panel_equip_full", "装备槽已满");
|
||||
return;
|
||||
}
|
||||
// 开启装备面板需支付金币,金币不足则提示并中止
|
||||
if (!this.tryPayPanelOpenCost(1)) return;
|
||||
this.slideToPanel(1);
|
||||
|
||||
Reference in New Issue
Block a user