feat(hero box): 添加英雄面板空槽位点击交互

1. 新增GameEvent.HeroBoxEmptyClick事件用于空槽位点击通知
2. 为HeroBoxComp添加空槽位节点和点击回调,播放点击动画并派发事件
3. 在MissionCardComp中注册该事件,点击时打开英雄卡池选择界面
4. 完善空槽位的显示/隐藏逻辑
This commit is contained in:
pan
2026-07-28 16:45:16 +08:00
parent 15a98f985b
commit 501a1e0703
4 changed files with 559 additions and 329 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -84,5 +84,6 @@ export enum GameEvent {
RemoveSkillBox = "RemoveSkillBox", // 技能盒销毁事件
UseEquipCard = "UseEquipCard", // 装备卡购买使用事件
RemoveEquipBox = "RemoveEquipBox", // 装备盒销毁事件
HeroBoxEmptyClick = "HeroBoxEmptyClick", // 英雄面板空槽位点击事件(展示英雄卡池)
}

View File

@@ -12,10 +12,11 @@
* - HeroInfoheroSet—— 英雄静态配置
*/
import { mLogger } from "../common/Logger";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType, UITransform } from "cc";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType, UITransform, Tween, tween, Vec3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { getLvColor } from "../common/config/GameSet";
@@ -47,6 +48,10 @@ export class HeroBoxComp extends CCComp {
@property(Label)
private level_label: Label = null;
/** 空槽位标识节点(未绑定英雄时激活,点击打开英雄卡池) */
@property(Node)
private noHero: Node = null;
// ======================== 战斗信息标签(总值 + 附加值) ========================
/** 攻击总值 */
@@ -159,12 +164,37 @@ export class HeroBoxComp extends CCComp {
// 次级属性栏默认收起
this.setMoreRowsVisible(false);
this.more_btn?.on(NodeEventType.TOUCH_END, this.onMoreBtnClick, this);
// 空槽位点击 → 打开英雄卡池
this.noHero?.on(NodeEventType.TOUCH_END, this.onNoHeroClick, this);
}
onDestroy() {
if (this.more_btn && this.more_btn.isValid) {
this.more_btn.off(NodeEventType.TOUCH_END, this.onMoreBtnClick, this);
}
if (this.noHero && this.noHero.isValid) {
this.noHero.off(NodeEventType.TOUCH_END, this.onNoHeroClick, this);
}
}
/**
* 空槽位点击:播放主节点点击动画,并派发事件通知 MissionCardComp 展示英雄卡池。
*/
private onNoHeroClick() {
oops.audio.playEffect("music/button");
this.playClickAnim();
oops.message.dispatchEvent(GameEvent.HeroBoxEmptyClick);
}
/** 主节点点击动画:缩放按下 → 回弹 */
private playClickAnim() {
if (!this.node || !this.node.isValid) return;
Tween.stopAllByTarget(this.node);
this.node.setScale(1, 1, 1);
tween(this.node)
.to(0.06, { scale: new Vec3(0.94, 0.94, 1) })
.to(0.1, { scale: new Vec3(1, 1, 1) })
.start();
}
/** 刷新计时累计(降频刷新实时属性) */
@@ -254,6 +284,9 @@ export class HeroBoxComp extends CCComp {
this.eid = eid;
this.model = model;
this.node.active = true;
if (this.noHero && this.noHero.isValid) {
this.noHero.active = false;
}
this.refresh();
}
@@ -264,6 +297,10 @@ export class HeroBoxComp extends CCComp {
this.iconHeroUuid = 0;
this.iconVisualToken += 1;
if (this.noHero && this.noHero.isValid) {
this.noHero.active = true;
}
if (this.name_label && this.name_label.isValid) {
this.name_label.string = "";
}

View File

@@ -388,6 +388,7 @@ export class MissionCardComp extends CCComp {
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.on(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.on(GameEvent.CardUsed, this.onCardUsed, this);
oops.message.on(GameEvent.HeroBoxEmptyClick, this.onHeroBoxEmptyClick, this);
/** 按钮触控事件:抽卡 */
this.cards_chou?.on(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
@@ -629,6 +630,7 @@ export class MissionCardComp extends CCComp {
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.off(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.off(GameEvent.CardUsed, this.onCardUsed, this);
oops.message.off(GameEvent.HeroBoxEmptyClick, this.onHeroBoxEmptyClick, this);
if (this.cards_chou && this.cards_chou.isValid) {
this.cards_chou.off(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
this.cards_chou.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this);
@@ -716,6 +718,11 @@ export class MissionCardComp extends CCComp {
this.refreshHeroBoxSlots();
}
/** 英雄面板空槽位点击回调:展示英雄卡池选择界面 */
private onHeroBoxEmptyClick() {
this.onShowCardsClick();
}
/**
* 使用英雄卡的 guard 校验(由 CHeroComp 通过 UseHeroCard 事件调用):
* - 当前英雄数 < 上限 → 允许使用。