feat(ui): 重构英雄卡AP/HP显示逻辑并调整卡牌布局
- 移除旧的 info_node 引用,改为直接绑定 ap_node 和 hp_node - 调整卡牌原始定位点位置以优化布局 - 在 prefab 中添加独立的 AP 和 HP 显示节点 - 更新显示逻辑,根据卡牌类型控制 AP/HP 面板的显隐
This commit is contained in:
@@ -55,9 +55,9 @@ export class CardComp extends CCComp {
|
||||
/** 解锁态图标节点(显示时表示本槽位未锁定,可点击上锁) */
|
||||
@property(Node)
|
||||
unLock: Node = null!
|
||||
/** 英雄卡信息面板(显示 AP / HP) */
|
||||
@property(Node)
|
||||
info_node=null!
|
||||
/** 英雄卡信息面板(显示 AP / HP) 废弃,改用直接绑定 */
|
||||
// @property(Node)
|
||||
// info_node=null!
|
||||
/** 非英雄卡信息面板(显示技能 / 特殊卡描述文本) */
|
||||
@property(Node)
|
||||
oinfo_node=null!
|
||||
@@ -85,6 +85,10 @@ export class CardComp extends CCComp {
|
||||
|
||||
@property(Node)
|
||||
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){
|
||||
// 英雄卡:显示英雄名 + 星级 + AP/HP
|
||||
const hero = HeroInfo[this.card_uuid];
|
||||
const heroLv = Math.max(1, Math.floor(this.cardData.hero_lv ?? hero?.lv ?? 1));
|
||||
const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : "";
|
||||
this.setLabel(this.name_node, `${suffix}${hero?.name || ""}${suffix}`);
|
||||
this.info_node.getChildByName("ap").getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
|
||||
this.info_node.getChildByName("hp").getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
|
||||
this.ap_node.getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
|
||||
this.hp_node.getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
|
||||
if (this.oinfo_node) {
|
||||
const infoLabel = this.oinfo_node.getChildByName("info")?.getComponent(Label);
|
||||
if (infoLabel) infoLabel.string = `${hero?.info || ""}`;
|
||||
}
|
||||
|
||||
this.ap_node.active = true;
|
||||
this.hp_node.active = true;
|
||||
|
||||
if (this.isEnlarged) {
|
||||
this.info_node.active = true;
|
||||
this.oinfo_node.active = true;
|
||||
} else {
|
||||
this.info_node.active = false;
|
||||
this.oinfo_node.active = false;
|
||||
}
|
||||
}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.oinfo_node.getChildByName("info").getComponent(Label).string = `${skillCard?.info || skill?.info || ""}`;
|
||||
|
||||
this.ap_node.active = false;
|
||||
this.hp_node.active = false;
|
||||
|
||||
if (this.isEnlarged) {
|
||||
this.info_node.active = false;
|
||||
this.oinfo_node.active = true;
|
||||
} else {
|
||||
this.info_node.active = false;
|
||||
this.oinfo_node.active = false;
|
||||
}
|
||||
}else{
|
||||
@@ -838,11 +853,12 @@ export class CardComp extends CCComp {
|
||||
this.setLabel(this.name_node, `${spSuffix}${specialCard?.name || ""}${spSuffix}`);
|
||||
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${specialCard?.info || ""}`;
|
||||
|
||||
this.ap_node.active = false;
|
||||
this.hp_node.active = false;
|
||||
|
||||
if (this.isEnlarged) {
|
||||
this.info_node.active = false;
|
||||
this.oinfo_node.active = true;
|
||||
} else {
|
||||
this.info_node.active = false;
|
||||
this.oinfo_node.active = false;
|
||||
}
|
||||
}
|
||||
@@ -1045,7 +1061,8 @@ export class CardComp extends CCComp {
|
||||
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.Ckind_node) {
|
||||
// this.Ckind_node.children.forEach(child => {
|
||||
|
||||
@@ -141,7 +141,7 @@ export class MissionCardComp extends CCComp {
|
||||
/** 卡牌面板收起态缩放(scale=0 隐藏) */
|
||||
private cardsHideScale: Vec3 = new Vec3(0, 0, 1);
|
||||
/** 卡牌原始定位点 */
|
||||
private cardsPos = [-260,-86,86,260]
|
||||
private cardsPos = [-260,-75,108,260]
|
||||
/**
|
||||
* 英雄信息面板映射:EID → { node, model, comp }
|
||||
* 用于追踪每个出战英雄的面板实例和数据引用
|
||||
|
||||
Reference in New Issue
Block a user