From bdb4602fe66f335fed09fc1c0f2a7957ca0196c4 Mon Sep 17 00:00:00 2001 From: pan Date: Fri, 31 Jul 2026 10:06:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(map):=20=E7=A7=BB=E9=99=A4=E5=9B=9B?= =?UTF-8?q?=E4=B8=AA=E5=8D=A1=E7=89=8C=E7=BB=84=E4=BB=B6=E7=9A=84=E9=95=BF?= =?UTF-8?q?=E6=8C=89=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除了EquipListComp、SCardComp、CHeroComp、ItemListComp四个文件中的长按弹出信息框相关代码,包括事件监听、长按计时逻辑和信息框打开关闭代码,同时删除了未使用的UIID导入。 --- assets/script/game/map/CHeroComp.ts | 58 -------------------- assets/script/game/map/EquipListComp.ts | 51 ------------------ assets/script/game/map/ItemListComp.ts | 72 ------------------------- assets/script/game/map/SCardComp.ts | 52 ------------------ 4 files changed, 233 deletions(-) diff --git a/assets/script/game/map/CHeroComp.ts b/assets/script/game/map/CHeroComp.ts index 31ac476a..81cb47e7 100644 --- a/assets/script/game/map/CHeroComp.ts +++ b/assets/script/game/map/CHeroComp.ts @@ -24,7 +24,6 @@ import { HeroInfo } from "../common/config/heroSet"; import { oops } from "db://oops-framework/core/Oops"; import { GameEvent } from "../common/config/GameEvent"; import { smc } from "../common/SingletonModuleComp"; -import { UIID } from "../common/config/GameUIConfig"; import { HeroAttrsComp } from "../hero/HeroAttrsComp"; import { FieldSkillType } from "../common/config/SkillSet"; import { FieldSkillHelper } from "../hero/FieldSkillHelper"; @@ -121,11 +120,6 @@ export class CHeroComp extends CCComp { this.buy_node?.on(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node?.on(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); - // 卡面长按弹信息框:按下启动计时,放开/取消时关闭 - this.node.on(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.on(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.on(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); - // 缓存透明度组件(用于淡入淡出动画) this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity); @@ -143,13 +137,6 @@ export class CHeroComp extends CCComp { this.buy_node.off(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node.off(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); } - if (this.node && this.node.isValid) { - this.node.off(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.off(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.off(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); - } - // 清理长按计时器,防止销毁后回调访问失效节点 - this.unschedule(this.showInfo); } // ======================== 数据初始化 ======================== @@ -546,51 +533,6 @@ export class CHeroComp extends CCComp { }); } - // ======================== 长按信息框 ======================== - - /** 长按时长(秒) */ - private static readonly LONG_PRESS_TIME: number = 0.5; - /** 信息框是否已弹出(区分长按完成与短按取消) */ - private info_shown: boolean = false; - - /** 卡面按下:启动长按计时 */ - private onInfoTouchStart() { - if (!this.cardData) return; - this.info_shown = false; - this.scheduleOnce(this.showInfo, CHeroComp.LONG_PRESS_TIME); - } - - /** 卡面放开/取消:已弹出则关闭信息框,未弹出则取消长按计时 */ - private onInfoTouchEnd() { - this.unschedule(this.showInfo); - if (this.info_shown) { - this.info_shown = false; - // oops.gui 移除信息框 - oops.gui.remove(UIID.HInfo); - } - } - - /** - * 长按到点:弹出英雄信息框。 - * 升级卡(SpecialUpgrade + target_hero_eid)通过 eid 反查场上实体得到 hero_uuid, - * 与 updateUI 的渲染逻辑保持一致。 - */ - private showInfo() { - if (!this.cardData) return; - this.info_shown = true; - - const isUpgradeCard = this.cardData.type === CardType.SpecialUpgrade && !!this.cardData.target_hero_eid; - const heroUuid = isUpgradeCard - ? (this.queryHeroUuidByEid(this.cardData.target_hero_eid as number) ?? this.cardData.uuid) - : this.cardData.uuid; - const heroLv = Math.max(1, this.cardData.hero_lv ?? 1); - const poolLv = Math.max(1, this.cardData.base_card_lv ?? this.cardData.card_lv ?? 1); - - // oops.gui 打开 HInfo 英雄卡预览 - oops.gui.remove(UIID.HInfo); - oops.gui.open(UIID.HInfo, { heroUuid, heroLv, poolLv }); - } - // ======================== 购买逻辑 ======================== /** diff --git a/assets/script/game/map/EquipListComp.ts b/assets/script/game/map/EquipListComp.ts index 8421eb3e..f256a8af 100644 --- a/assets/script/game/map/EquipListComp.ts +++ b/assets/script/game/map/EquipListComp.ts @@ -21,7 +21,6 @@ import { FieldSkillSet } from "../common/config/SkillSet"; import { oops } from "db://oops-framework/core/Oops"; import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper"; import { GameEvent } from "../common/config/GameEvent"; -import { UIID } from "../common/config/GameUIConfig"; import { MissionEconomy } from "./MissionEconomy"; const { ccclass, property } = _decorator; @@ -92,10 +91,6 @@ export class EquipListComp extends CCComp { this.buy_node?.on(NodeEventType.TOUCH_START, this.onBuyTouchStart, this); this.buy_node?.on(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node?.on(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); - // 卡面长按弹信息框:按下启动计时,放开/取消时关闭 - this.node.on(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.on(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.on(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity); } @@ -106,13 +101,6 @@ export class EquipListComp extends CCComp { this.buy_node.off(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node.off(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); } - if (this.node && this.node.isValid) { - this.node.off(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.off(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.off(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); - } - // 清理长按计时器,防止销毁后回调访问失效节点 - this.unschedule(this.showInfo); } // ======================== 数据初始化 ======================== @@ -333,45 +321,6 @@ export class EquipListComp extends CCComp { .start(); } - // ======================== 长按信息框 ======================== - - /** 长按时长(秒) */ - private static readonly LONG_PRESS_TIME: number = 0.5; - /** 信息框是否已弹出(区分长按完成与短按取消) */ - private info_shown: boolean = false; - - /** 卡面按下:启动长按计时 */ - private onInfoTouchStart() { - if (!this.cardData) return; - this.info_shown = false; - this.scheduleOnce(this.showInfo, EquipListComp.LONG_PRESS_TIME); - } - - /** 卡面放开/取消:已弹出则关闭信息框,未弹出则取消长按计时 */ - private onInfoTouchEnd() { - this.unschedule(this.showInfo); - if (this.info_shown) { - this.info_shown = false; - // oops.gui 移除信息框 - oops.gui.remove(UIID.HInfo); - } - } - - /** 长按到点:弹出装备信息框 */ - private showInfo() { - if (!this.cardData) return; - this.info_shown = true; - // oops.gui 打开 HInfo 装备卡预览(复用 EquipBoxComp 的打开参数) - oops.gui.remove(UIID.HInfo); - oops.gui.open(UIID.HInfo, { - heroUuid: this.cardData.uuid, - heroLv: this.cardData.card_lv ?? 1, - poolLv: 1, - isSkillCard: true, - isEquipCard: true - }); - } - // ======================== 购买逻辑 ======================== /** diff --git a/assets/script/game/map/ItemListComp.ts b/assets/script/game/map/ItemListComp.ts index 9f38f77a..faa03e71 100644 --- a/assets/script/game/map/ItemListComp.ts +++ b/assets/script/game/map/ItemListComp.ts @@ -19,12 +19,10 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CardConfig, CardTriggerType, CKind } from "../common/config/CardSet"; import { EquipPoolList } from "../common/config/EquipSet"; -import { SkillCardList } from "../common/config/SCardSet"; import { FieldSkillSet, SkillSet } from "../common/config/SkillSet"; import { oops } from "db://oops-framework/core/Oops"; import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper"; import { GameEvent } from "../common/config/GameEvent"; -import { UIID } from "../common/config/GameUIConfig"; import { MissionEconomy } from "./MissionEconomy"; const { ccclass, property } = _decorator; @@ -95,10 +93,6 @@ export class ItemListComp extends CCComp { this.buy_node?.on(NodeEventType.TOUCH_START, this.onBuyTouchStart, this); this.buy_node?.on(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node?.on(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); - // 卡面长按弹信息框:按下启动计时,放开/取消时关闭 - this.node.on(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.on(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.on(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity); } @@ -109,13 +103,6 @@ export class ItemListComp extends CCComp { this.buy_node.off(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node.off(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); } - if (this.node && this.node.isValid) { - this.node.off(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.off(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.off(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); - } - // 清理长按计时器,防止销毁后回调访问失效节点 - this.unschedule(this.showInfo); } // ======================== 数据初始化 ======================== @@ -370,65 +357,6 @@ export class ItemListComp extends CCComp { .start(); } - // ======================== 长按信息框 ======================== - - /** 长按时长(秒) */ - private static readonly LONG_PRESS_TIME: number = 0.5; - /** 信息框是否已弹出(区分长按完成与短按取消) */ - private info_shown: boolean = false; - - /** 卡面按下:启动长按计时 */ - private onInfoTouchStart() { - if (!this.cardData) return; - this.info_shown = false; - this.scheduleOnce(this.showInfo, ItemListComp.LONG_PRESS_TIME); - } - - /** 卡面放开/取消:已弹出则关闭信息框,未弹出则取消长按计时 */ - private onInfoTouchEnd() { - this.unschedule(this.showInfo); - if (this.info_shown) { - this.info_shown = false; - // oops.gui 移除信息框 - oops.gui.remove(UIID.HInfo); - } - } - - /** - * 长按到点:按卡牌类型弹出对应信息框。 - * - 装备卡(trigger_type=Field)→ 装备预览(isEquipCard) - * - 商品/药品及其他 → 技能卡预览(uuid 反查 SkillCardList) - */ - private showInfo() { - if (!this.cardData) return; - this.info_shown = true; - - const isEquip = this.cardData.trigger_type === CardTriggerType.Field; - if (isEquip) { - // oops.gui 打开 HInfo 装备卡预览(复用 EquipBoxComp 的打开参数) - oops.gui.remove(UIID.HInfo); - oops.gui.open(UIID.HInfo, { - heroUuid: this.cardData.uuid, - heroLv: this.cardData.card_lv ?? 1, - poolLv: 1, - isSkillCard: true, - isEquipCard: true - }); - return; - } - - // 技能/商品卡:反查 SkillCardList 拿到卡池 uuid(查不到时降级为本卡 uuid) - const config = SkillCardList.find(c => c.uuid === this.cardData!.uuid || c.skill === this.cardData!.uuid); - const cardUuid = config ? config.uuid : this.cardData.uuid; - oops.gui.remove(UIID.HInfo); - oops.gui.open(UIID.HInfo, { - heroUuid: cardUuid, - heroLv: this.cardData.card_lv ?? 1, - poolLv: config?.card_lv ?? 1, - isSkillCard: true - }); - } - // ======================== 购买逻辑 ======================== /** diff --git a/assets/script/game/map/SCardComp.ts b/assets/script/game/map/SCardComp.ts index 8cf1dc45..c7999655 100644 --- a/assets/script/game/map/SCardComp.ts +++ b/assets/script/game/map/SCardComp.ts @@ -21,7 +21,6 @@ import { oops } from "db://oops-framework/core/Oops"; import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper"; import { GameEvent } from "../common/config/GameEvent"; import { smc } from "../common/SingletonModuleComp"; -import { UIID } from "../common/config/GameUIConfig"; import { MissionEconomy } from "./MissionEconomy"; const { ccclass, property } = _decorator; @@ -92,10 +91,6 @@ export class SCardComp extends CCComp { this.buy_node?.on(NodeEventType.TOUCH_START, this.onBuyTouchStart, this); this.buy_node?.on(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node?.on(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); - // 卡面长按弹信息框:按下启动计时,放开/取消时关闭 - this.node.on(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.on(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.on(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity); } @@ -106,13 +101,6 @@ export class SCardComp extends CCComp { this.buy_node.off(NodeEventType.TOUCH_END, this.onBuyClick, this); this.buy_node.off(NodeEventType.TOUCH_CANCEL, this.onBuyTouchCancel, this); } - if (this.node && this.node.isValid) { - this.node.off(NodeEventType.TOUCH_START, this.onInfoTouchStart, this); - this.node.off(NodeEventType.TOUCH_END, this.onInfoTouchEnd, this); - this.node.off(NodeEventType.TOUCH_CANCEL, this.onInfoTouchEnd, this); - } - // 清理长按计时器,防止销毁后回调访问失效节点 - this.unschedule(this.showInfo); } // ======================== 数据初始化 ======================== @@ -379,46 +367,6 @@ export class SCardComp extends CCComp { return skillCard?.info || skill?.info || this.cardData.info || ""; } - // ======================== 长按信息框 ======================== - - /** 长按时长(秒) */ - private static readonly LONG_PRESS_TIME: number = 0.5; - /** 信息框是否已弹出(区分长按完成与短按取消) */ - private info_shown: boolean = false; - - /** 卡面按下:启动长按计时 */ - private onInfoTouchStart() { - if (!this.cardData) return; - this.info_shown = false; - this.scheduleOnce(this.showInfo, SCardComp.LONG_PRESS_TIME); - } - - /** 卡面放开/取消:已弹出则关闭信息框,未弹出则取消长按计时 */ - private onInfoTouchEnd() { - this.unschedule(this.showInfo); - if (this.info_shown) { - this.info_shown = false; - // oops.gui 移除信息框 - oops.gui.remove(UIID.HInfo); - } - } - - /** 长按到点:弹出技能卡信息框 */ - private showInfo() { - if (!this.cardData) return; - this.info_shown = true; - // oops.gui 打开 HInfo 技能卡预览(复用 SkillBoxComp 的查询逻辑) - const config = SkillCardList.find(c => c.uuid === this.cardData!.uuid || c.skill === this.cardData!.uuid); - const cardUuid = config ? config.uuid : this.cardData.uuid; - oops.gui.remove(UIID.HInfo); - oops.gui.open(UIID.HInfo, { - heroUuid: cardUuid, - heroLv: this.cardData.card_lv ?? 1, - poolLv: config?.card_lv ?? 1, - isSkillCard: true - }); - } - // ======================== 购买逻辑 ======================== /**