feat: 添加英雄信息弹窗显示功能

- 在卡牌点击时打开英雄技能信息弹窗
- 为英雄头像信息组件添加点击打开弹窗功能
- 重构信息弹窗组件,支持动态显示英雄技能信息
- 调整弹窗UI布局和尺寸以适应不同数量的技能显示
This commit is contained in:
walkpan
2026-03-27 19:24:29 +08:00
parent 2d6f46dc42
commit b88d3c214a
4 changed files with 161 additions and 59 deletions

View File

@@ -1,8 +1,10 @@
import { _decorator, Animation, AnimationClip, Label, Node, Sprite, resources } from "cc";
import { _decorator, Animation, AnimationClip, Label, Node, NodeEventType, Sprite, resources } 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 { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { oops } from "db://oops-framework/core/Oops";
import { UIID } from "../common/config/GameUIConfig";
const {property, ccclass } = _decorator;
@@ -21,6 +23,11 @@ export class HInfoComp extends CCComp {
onLoad() {
this.cacheLabels();
this.bindEvents();
}
onDestroy() {
this.unbindEvents();
}
bindData(eid: number, model: HeroAttrsComp) {
@@ -116,6 +123,27 @@ export class HInfoComp extends CCComp {
[...clips].forEach(clip => anim.removeClip(clip, true));
}
private bindEvents() {
this.node.on(NodeEventType.TOUCH_END, this.onOpenIBox, this);
}
private unbindEvents() {
this.node.off(NodeEventType.TOUCH_END, this.onOpenIBox, this);
}
private onOpenIBox() {
if (!this.model) return;
const heroUuid = this.model.hero_uuid ?? 0;
if (!heroUuid || !HeroInfo[heroUuid]) return;
const heroLv = Math.max(1, Math.floor(this.model.lv ?? 1));
oops.gui.remove(UIID.IBox);
oops.gui.open(UIID.IBox, {
heroUuid,
heroLv,
skills: this.model.skills
});
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.clearIconAnimation(this.icon_node);