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

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 = "";
}