feat(ui): 重构英雄卡AP/HP显示逻辑并调整卡牌布局

- 移除旧的 info_node 引用,改为直接绑定 ap_node 和 hp_node
- 调整卡牌原始定位点位置以优化布局
- 在 prefab 中添加独立的 AP 和 HP 显示节点
- 更新显示逻辑,根据卡牌类型控制 AP/HP 面板的显隐
This commit is contained in:
panw
2026-04-24 10:23:50 +08:00
parent 051342a9c4
commit 955465da58
4 changed files with 2204 additions and 1172 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -55,9 +55,9 @@ export class CardComp extends CCComp {
/** 解锁态图标节点(显示时表示本槽位未锁定,可点击上锁) */ /** 解锁态图标节点(显示时表示本槽位未锁定,可点击上锁) */
@property(Node) @property(Node)
unLock: Node = null! unLock: Node = null!
/** 英雄卡信息面板(显示 AP / HP */ /** 英雄卡信息面板(显示 AP / HP 废弃,改用直接绑定 */
@property(Node) // @property(Node)
info_node=null! // info_node=null!
/** 非英雄卡信息面板(显示技能 / 特殊卡描述文本) */ /** 非英雄卡信息面板(显示技能 / 特殊卡描述文本) */
@property(Node) @property(Node)
oinfo_node=null! oinfo_node=null!
@@ -85,6 +85,10 @@ export class CardComp extends CCComp {
@property(Node) @property(Node)
lv_node=null! lv_node=null!
@property(Node)
ap_node=null!
@property(Node)
hp_node=null!
// ======================== 运行时状态 ======================== // ======================== 运行时状态 ========================
@@ -792,24 +796,34 @@ export class CardComp extends CCComp {
}); });
}); });
if (this.ap_node) {
const widget = this.ap_node.getComponent(Widget);
if (widget) widget.updateAlignment();
}
if (this.hp_node) {
const widget = this.hp_node.getComponent(Widget);
if (widget) widget.updateAlignment();
}
if(this.card_type===CardType.Hero){ if(this.card_type===CardType.Hero){
// 英雄卡:显示英雄名 + 星级 + AP/HP // 英雄卡:显示英雄名 + 星级 + AP/HP
const hero = HeroInfo[this.card_uuid]; const hero = HeroInfo[this.card_uuid];
const heroLv = Math.max(1, Math.floor(this.cardData.hero_lv ?? hero?.lv ?? 1)); const heroLv = Math.max(1, Math.floor(this.cardData.hero_lv ?? hero?.lv ?? 1));
const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : ""; const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : "";
this.setLabel(this.name_node, `${suffix}${hero?.name || ""}${suffix}`); this.setLabel(this.name_node, `${suffix}${hero?.name || ""}${suffix}`);
this.info_node.getChildByName("ap").getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`; this.ap_node.getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
this.info_node.getChildByName("hp").getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`; this.hp_node.getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
if (this.oinfo_node) { if (this.oinfo_node) {
const infoLabel = this.oinfo_node.getChildByName("info")?.getComponent(Label); const infoLabel = this.oinfo_node.getChildByName("info")?.getComponent(Label);
if (infoLabel) infoLabel.string = `${hero?.info || ""}`; if (infoLabel) infoLabel.string = `${hero?.info || ""}`;
} }
this.ap_node.active = true;
this.hp_node.active = true;
if (this.isEnlarged) { if (this.isEnlarged) {
this.info_node.active = true;
this.oinfo_node.active = true; this.oinfo_node.active = true;
} else { } else {
this.info_node.active = false;
this.oinfo_node.active = false; this.oinfo_node.active = false;
} }
}else if(this.card_type===CardType.Skill){ }else if(this.card_type===CardType.Skill){
@@ -821,11 +835,12 @@ export class CardComp extends CCComp {
this.setLabel(this.name_node, `${spSuffix}${skillCard?.name || skill?.name || ""}${spSuffix}`); this.setLabel(this.name_node, `${spSuffix}${skillCard?.name || skill?.name || ""}${spSuffix}`);
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${skillCard?.info || skill?.info || ""}`; this.oinfo_node.getChildByName("info").getComponent(Label).string = `${skillCard?.info || skill?.info || ""}`;
this.ap_node.active = false;
this.hp_node.active = false;
if (this.isEnlarged) { if (this.isEnlarged) {
this.info_node.active = false;
this.oinfo_node.active = true; this.oinfo_node.active = true;
} else { } else {
this.info_node.active = false;
this.oinfo_node.active = false; this.oinfo_node.active = false;
} }
}else{ }else{
@@ -838,11 +853,12 @@ export class CardComp extends CCComp {
this.setLabel(this.name_node, `${spSuffix}${specialCard?.name || ""}${spSuffix}`); this.setLabel(this.name_node, `${spSuffix}${specialCard?.name || ""}${spSuffix}`);
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${specialCard?.info || ""}`; this.oinfo_node.getChildByName("info").getComponent(Label).string = `${specialCard?.info || ""}`;
this.ap_node.active = false;
this.hp_node.active = false;
if (this.isEnlarged) { if (this.isEnlarged) {
this.info_node.active = false;
this.oinfo_node.active = true; this.oinfo_node.active = true;
} else { } else {
this.info_node.active = false;
this.oinfo_node.active = false; this.oinfo_node.active = false;
} }
} }
@@ -1045,7 +1061,8 @@ export class CardComp extends CCComp {
this.setLabel(numNode, ""); this.setLabel(numNode, "");
} }
} }
if (this.info_node) this.info_node.active = false; if (this.ap_node) this.ap_node.active = false;
if (this.hp_node) this.hp_node.active = false;
if (this.oinfo_node) this.oinfo_node.active = false; if (this.oinfo_node) this.oinfo_node.active = false;
// if (this.Ckind_node) { // if (this.Ckind_node) {
// this.Ckind_node.children.forEach(child => { // this.Ckind_node.children.forEach(child => {

View File

@@ -141,7 +141,7 @@ export class MissionCardComp extends CCComp {
/** 卡牌面板收起态缩放scale=0 隐藏) */ /** 卡牌面板收起态缩放scale=0 隐藏) */
private cardsHideScale: Vec3 = new Vec3(0, 0, 1); private cardsHideScale: Vec3 = new Vec3(0, 0, 1);
/** 卡牌原始定位点 */ /** 卡牌原始定位点 */
private cardsPos = [-260,-86,86,260] private cardsPos = [-260,-75,108,260]
/** /**
* 英雄信息面板映射EID → { node, model, comp } * 英雄信息面板映射EID → { node, model, comp }
* 用于追踪每个出战英雄的面板实例和数据引用 * 用于追踪每个出战英雄的面板实例和数据引用