feat(界面): 完善任务卡片组件的交互功能

- 为商店类型卡片添加关闭按钮及点击事件处理
- 修复卡片选中状态显示问题,添加选中动画效果
- 优化关闭逻辑,避免按钮显示闪烁
- 启用物理系统调试绘制功能
- 禁用角色控制器中的某个节点
This commit is contained in:
walkpan
2026-01-06 11:12:30 +08:00
parent 534067f566
commit c5c61c92e3
3 changed files with 36 additions and 6 deletions

View File

@@ -8461,7 +8461,7 @@
"node": {
"__id__": 394
},
"_enabled": true,
"_enabled": false,
"__prefab": {
"__id__": 412
},

View File

@@ -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>(Initialize);

View File

@@ -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();
}