refactor(hero-ui): 重构英雄信息面板为点击弹窗形式

本次修改完成以下核心调整:
1.  在GameUIConfig中注册HInfo弹窗的UIID与预制体路径
2.  为场上英雄节点添加点击交互,点击时打开对应英雄的信息弹窗
3.  清理MissionCardComp中常驻英雄信息面板的旧逻辑代码
4.  重构HInfoComp适配弹窗模式,支持按实体ID绑定英雄数据并实时刷新显示
5.  调整CardComp中英雄图标缩放,优化界面显示效果
This commit is contained in:
walkpan
2026-05-24 16:16:40 +08:00
parent 981f3a43b9
commit 1b26a9079d
10 changed files with 8775 additions and 5475 deletions

View File

@@ -41,7 +41,6 @@ import { CARD_POOL_INIT_LEVEL, CARD_POOL_MAX_LEVEL, CARD_POOL_UPGRADE_DISCOUNT_P
import { CardComp } from "./CardComp";
import { oops } from "db://oops-framework/core/Oops";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { HInfoComp } from "./HInfoComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroInfo, HType } from "../common/config/heroSet";
import { HeroViewComp } from "../hero/HeroViewComp";
@@ -107,12 +106,6 @@ export class MissionCardComp extends CCComp {
/** 卡池等级显示节点 */
@property(Node)
pool_lv_node:Node = null!
/** 场上英雄信息面板容器节点HInfoComp 实例的父节点) */
@property(Node)
hero_info_node:Node = null!
/** 英雄信息面板预制体(每个英雄上场时实例化一份) */
@property(Prefab)
hero_info_prefab:Prefab=null!
/** 英雄数量显示节点(含 icon + num 子节点) */
@property(Node)
hero_num_node:Node=null!
@@ -126,12 +119,6 @@ export class MissionCardComp extends CCComp {
private cardComps: CardComp[] = [];
/** 当前卡池等级(仅影响抽卡来源,不直接改卡槽现有内容) */
private poolLv: number = CARD_POOL_INIT_LEVEL;
/** 英雄信息面板项间距(像素) */
private readonly heroInfoItemGap: number = 135;
/** 英雄信息面板项间额外间距(像素) */
private readonly heroInfoItemSpacing: number = 5;
/** 英雄信息面板同步计时器(降频刷新用) */
private heroInfoSyncTimer: number = 0;
/** 是否已缓存卡牌面板基准缩放 */
private hasCachedCardsBaseScale: boolean = false;
/** 卡牌面板基准缩放(从场景读取) */
@@ -142,8 +129,7 @@ export class MissionCardComp extends CCComp {
private cardsHideScale: Vec3 = new Vec3(0, 0, 1);
/** 卡牌原始定位点 */
private cardsPos = [-260,-75,108,260]
/** 缓存预先放置的 6 个 HInfoComp */
private cachedHInfoComps: Map<number, HInfoComp> = new Map();
// ======================== 生命周期 ========================
/**
@@ -155,7 +141,6 @@ export class MissionCardComp extends CCComp {
* 5. 触发首次任务开始流程。
*/
onLoad() {
this.cacheHInfoComps();
this.bindEvents();
this.cacheCardComps();
this.layoutCardSlots();
@@ -167,19 +152,6 @@ export class MissionCardComp extends CCComp {
});
}
private cacheHInfoComps() {
this.cachedHInfoComps.clear();
if (!this.hero_info_node) return;
for (let i = 0; i < this.hero_info_node.children.length; i++) {
const child = this.hero_info_node.children[i];
const comp = (child.getComponent(HInfoComp) || child.getComponent("HInfoComp")) as HInfoComp;
if (comp && comp.node_index > 0) {
this.cachedHInfoComps.set(comp.node_index, comp);
child.active = false;
}
}
}
/** 组件销毁时解绑所有事件并清理英雄信息面板 */
onDestroy() {
super.onDestroy();
@@ -189,7 +161,6 @@ export class MissionCardComp extends CCComp {
this.cards_chou.off(NodeEventType.TOUCH_CANCEL, this.onDrawTouchCancel, this);
}
this.unbindEvents();
this.clearHeroInfoPanels();
}
/** 外部初始化入口(由 CardController 调用) */
@@ -223,7 +194,6 @@ export class MissionCardComp extends CCComp {
this.cacheCardComps();
}
this.clearHeroInfoPanels();
this.layoutCardSlots();
this.clearAllCards();
// if (this.cards_up) {
@@ -246,7 +216,6 @@ export class MissionCardComp extends CCComp {
/** 任务结束:清空 4 槽 + 英雄面板并隐藏整个节点 */
onMissionEnd() {
this.clearAllCards();
this.clearHeroInfoPanels();
if (this.node && this.node.isValid) {
this.node.active = false;
}
@@ -260,20 +229,8 @@ export class MissionCardComp extends CCComp {
* 检测已死亡 / 已失效的面板并移除,刷新存活面板属性。
*/
update(dt: number) {
this.heroInfoSyncTimer += dt;
if (this.heroInfoSyncTimer < 0.15) return;
this.heroInfoSyncTimer = 0;
// 遍历所有预设的 HInfoComp让其根据 node_index 自己刷新
this.cachedHInfoComps.forEach(comp => {
if (comp && comp.isValid) {
comp.refreshByNodeIndex();
}
});
}
/** 关闭面板(不销毁数据模型,仅隐藏) */
close() {
if (this.node && this.node.isValid) {
@@ -647,12 +604,6 @@ export class MissionCardComp extends CCComp {
this.cards_node.active = true;
Tween.stopAllByTarget(this.cards_node);
this.cards_node.setScale(this.cardsShowScale);
this.cachedHInfoComps.forEach(comp => {
if (comp && comp.isValid) {
comp.setBattlePhase(false);
}
});
}
private enterBattlePhase() {
@@ -668,12 +619,6 @@ export class MissionCardComp extends CCComp {
// }
// })
// .start();
this.cachedHInfoComps.forEach(comp => {
if (comp && comp.isValid) {
comp.setBattlePhase(true);
}
});
}
/** 构建本次抽卡结果保证最终可分发3条数据 */
@@ -874,21 +819,6 @@ export class MissionCardComp extends CCComp {
return Math.max(0, baseCost - discount);
}
private clearHeroInfoPanels() {
if (this.cachedHInfoComps) {
this.cachedHInfoComps.forEach(comp => {
if (comp && comp.node && comp.node.isValid) {
comp.node.active = false;
}
});
}
this.heroInfoSyncTimer = 0;
this.syncMissionHeroData(0);
this.updateHeroNumUI(false, false);
}
public setHeroMaxCount(max: number) {
const missionData = this.getMissionData();
if (!missionData) return;
@@ -1055,7 +985,6 @@ export class MissionCardComp extends CCComp {
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.clearHeroInfoPanels();
this.resetButtonScale(this.cards_chou);
// this.resetButtonScale(this.cards_up);