refactor(hero system): 重构英雄升级与卡片展示逻辑

1.  重构英雄升级方法,移除外部传入所需碎片参数,改为从配置表自动读取
2.  简化CardLiteComp.setHeroByUuid,移除卡池等级参数,直接读取英雄静态配置
3.  新增ChipComp.setHeroIconByUuid,重构英雄图标渲染逻辑
4.  新增英雄详情面板的升级功能与碎片展示
5.  新增英雄成长变化的事件监听与面板刷新逻辑
This commit is contained in:
panFD
2026-08-23 16:27:58 +08:00
parent 6eb51c8535
commit fb2c67ccab
6 changed files with 4752 additions and 1064 deletions

View File

@@ -79,39 +79,35 @@ export class ChipComp extends CCComp {
}
/**
* 便捷方法:通过英雄 UUID 和卡池等级直接设置英雄卡
* 自动从 CardPoolList 查找匹配的卡牌配置
* 通过英雄 UUID 直接渲染英雄图标(自动播放 idle 动画并应用背景)
* 适用于碎片、头像、图鉴等纯展示场景
* @param uuid 英雄 UUID
* @param cardLv 卡牌等级(默认 1
*/
setHeroByUuid(uuid: number, cardLv: number = 1) {
const card = CardPoolList.find(c => c.uuid === uuid && c.card_lv === cardLv);
if (card) {
this.setData(card);
return;
}
setHeroIconByUuid(uuid: number) {
const hero = HeroInfo[uuid];
if (hero) {
this.setData({
uuid: hero.uuid,
type: CardType.Hero,
cost: 0,
weight: 0,
card_lv: cardLv,
kind: CKind.Hero,
hero_lv: smc.getHeroOuterLv(hero.uuid)
if (!hero) return;
this.cardData = null;
this.card_uuid = uuid;
this.card_type = CardType.Hero;
this.node.active = true;
this.iconVisualToken += 1;
// 背景:按 HeroInfo.card_lv 应用英雄底框样式
if (this.BG_node) {
const cardLv = hero.card_lv ?? 1;
const kindName = CKind[CKind.Hero];
this.BG_node.children.forEach(child => {
child.active = (child.name === kindName);
const bg = child.getComponent(CardBgComp);
if (bg) child.active ? bg.apply(cardLv) : bg.clear();
});
}
}
/** 查询当前是否有卡牌数据 */
hasCard(): boolean {
return !!this.cardData;
}
/** 获取当前卡牌数据 */
getCardData(): CardConfig | null {
return this.cardData;
// 图标:英雄 idle 动画(带镜像翻转)
if (this.icon_node) {
this.icon_node.setScale(new Vec3(-1.5, 1.5, 1));
this.updateHeroAnimation(this.icon_node, uuid, this.iconVisualToken);
}
}
/** 清空卡牌数据并重置 UI */