From c5c61c92e3c57ceb0795d97d00e55acae4812a7a Mon Sep 17 00:00:00 2001 From: walkpan Date: Tue, 6 Jan 2026 11:12:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=95=8C=E9=9D=A2):=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8D=A1=E7=89=87=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为商店类型卡片添加关闭按钮及点击事件处理 - 修复卡片选中状态显示问题,添加选中动画效果 - 优化关闭逻辑,避免按钮显示闪烁 - 启用物理系统调试绘制功能 - 禁用角色控制器中的某个节点 --- assets/resources/gui/role_controller.prefab | 2 +- assets/script/Main.ts | 10 +++---- assets/script/game/map/MissionCardComp.ts | 30 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/assets/resources/gui/role_controller.prefab b/assets/resources/gui/role_controller.prefab index 51ca38c6..240821aa 100644 --- a/assets/resources/gui/role_controller.prefab +++ b/assets/resources/gui/role_controller.prefab @@ -8461,7 +8461,7 @@ "node": { "__id__": 394 }, - "_enabled": true, + "_enabled": false, "__prefab": { "__id__": 412 }, diff --git a/assets/script/Main.ts b/assets/script/Main.ts index bb5c2a5b..4cae125c 100644 --- a/assets/script/Main.ts +++ b/assets/script/Main.ts @@ -12,11 +12,11 @@ const { ccclass, property } = _decorator; @ccclass('Main') export class Main extends Root { start() { - // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb - // |EPhysics2DDrawFlags.Pair - // |EPhysics2DDrawFlags.CenterOfMass - // |EPhysics2DDrawFlags.Joint - // |EPhysics2DDrawFlags.Shape; + PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb + |EPhysics2DDrawFlags.Pair + |EPhysics2DDrawFlags.CenterOfMass + |EPhysics2DDrawFlags.Joint + |EPhysics2DDrawFlags.Shape; } protected async run() { smc.initialize = ecs.getEntity(Initialize); diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 210bd666..dde57a65 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -44,6 +44,10 @@ export class MissionCardComp extends CCComp { purchasedSlots: boolean[] = [false, false, false, false, false]; onLoad() { + if (this.btnClose) { + this.btnClose.on(Node.EventType.TOUCH_END, this.close, this); + } + oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this); oops.message.on(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this); oops.message.on(GameEvent.ShopOpen, this.onShopOpen, this); @@ -54,6 +58,10 @@ export class MissionCardComp extends CCComp { } onDestroy() { + if (this.btnClose) { + this.btnClose.off(Node.EventType.TOUCH_END, this.close, this); + } + oops.message.off(GameEvent.TalentSelect, this.onTalentSelect, this); oops.message.off(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this); oops.message.off(GameEvent.ShopOpen, this.onShopOpen, this); @@ -151,6 +159,12 @@ export class MissionCardComp extends CCComp { this.node.active = true; this.hasSelected = false; this.curCardType = type; + + // 仅在物品类型(商店)显示关闭按钮 + if (this.btnClose) { + this.btnClose.active = (type === CardType.Potion); + } + this.resetCardStates(); this.refCards(); this.playShowAnimation(); @@ -181,6 +195,8 @@ export class MissionCardComp extends CCComp { allData = CanSelectSkills.map(id => SkillSet[id]); } else if (this.curCardType === CardType.Partner) { allData = CanSelectHeros.map(id => HeroInfo[id]); + } else if (this.curCardType === CardType.Potion) { + allData = Object.values(ItemSet); } // 后续扩展其他类型 // else if (this.curCardType === CardType.Skill) { ... } @@ -277,6 +293,14 @@ export class MissionCardComp extends CCComp { const sprite = selectedCardNode.getComponent(Sprite); if (sprite) sprite.color = new Color(150, 150, 150); + // 激活 selected 组件 + const selected = selectedCardNode.getChildByName("selected"); + if(selected) { + selected.active = true; + selected.setScale(Vec3.ZERO); + tween(selected).to(0.2, { scale: new Vec3(1, 1, 1) }, { easing: 'backOut' }).start(); + } + oops.gui.toast("购买成功"); // 检查是否所有卡片都已购买,如果是则关闭 @@ -352,6 +376,12 @@ export class MissionCardComp extends CCComp { */ close() { this.node.active = false; + + // 关闭时隐藏按钮,避免下次打开其他类型时闪烁 + if (this.btnClose) { + this.btnClose.active = false; + } + this.checkQueue(); }