refactor(map): 优化槽位检测逻辑并新增满槽提示

1. 为MissEquipComp和MissSkillsComp新增静态实例缓存和isFull方法,避免强引用查询
2. 修复槽位坐标的空格格式问题
3. 扩展showSmallTip的参数类型,新增多种面板满槽提示场景
4. 在英雄、装备、技能面板开启逻辑中添加满槽校验和对应提示
This commit is contained in:
pan
2026-08-06 10:44:42 +08:00
parent 98135dc5a4
commit 7436944752
4 changed files with 1883 additions and 1196 deletions

View File

@@ -57,6 +57,19 @@ export class MissSkillsComp extends CCComp {
/** 调试日志开关 */
private debugMode: boolean = true;
/** 当前活跃实例(供其他系统查询槽位占用,避免直接 find 强引用) */
private static instance: MissSkillsComp | null = null;
/**
* 查询场上技能槽是否已全部占用。
* @returns 无空闲槽位时返回 true实例不存在时返回 false
*/
public static isFull(): boolean {
const inst = MissSkillsComp.instance;
if (!inst) return false;
return inst.slots.every(slot => slot.used);
}
/** 技能卡 Prefab在编辑器中赋值 */
@property({ type: Prefab })
private skill_box: Prefab = null;
@@ -65,16 +78,17 @@ export class MissSkillsComp extends CCComp {
* 预定义的 6 个槽位坐标(单行):
*/
private slots: SkillBoxSlot[] = [
{ x: -310, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: -240, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: -170, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: -100, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: -30, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: 40, y: BoxSet.GAME_LINE+300, used: false, node: null },
{ x: -310, y: BoxSet.GAME_LINE + 300, used: false, node: null },
{ x: -240, y: BoxSet.GAME_LINE + 300, used: false, node: null },
{ x: -170, y: BoxSet.GAME_LINE + 300, used: false, node: null },
{ x: -100, y: BoxSet.GAME_LINE + 300, used: false, node: null },
{ x: -30, y: BoxSet.GAME_LINE + 300, used: false, node: null },
{ x: 40, y: BoxSet.GAME_LINE + 300, used: false, node: null },
];
/** 注册事件监听 */
onLoad() {
MissSkillsComp.instance = this;
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this);
oops.message.on(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
@@ -83,6 +97,9 @@ export class MissSkillsComp extends CCComp {
/** 移除事件监听 */
onDestroy() {
super.onDestroy();
if (MissSkillsComp.instance === this) {
MissSkillsComp.instance = null;
}
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
oops.message.off(GameEvent.UseItemCard, this.onUseItemCard, this);
oops.message.off(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);