refactor(map): 移除冗余的卡池等级节点并重构显示逻辑
1. 删除HInfoComp和CardLiteComp中不再使用的pool_lv相关节点字段 2. 将卡池等级背景色显示逻辑迁移到HerosListComp中统一处理 3. 简化CardLiteComp的节点初始化隐藏逻辑
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -53,8 +53,6 @@ export class CardLiteComp extends CCComp {
|
|||||||
Ckind_node: Node = null!
|
Ckind_node: Node = null!
|
||||||
@property(Node)
|
@property(Node)
|
||||||
BG_node: Node = null!
|
BG_node: Node = null!
|
||||||
@property(Node)
|
|
||||||
pool_lv_node: Node = null!
|
|
||||||
@property(Label)
|
@property(Label)
|
||||||
lvl_node: Label = null!
|
lvl_node: Label = null!
|
||||||
|
|
||||||
@@ -211,10 +209,7 @@ export class CardLiteComp extends CCComp {
|
|||||||
hasIcon: !!this.icon_node,
|
hasIcon: !!this.icon_node,
|
||||||
hasCost: !!this.cost_node,
|
hasCost: !!this.cost_node,
|
||||||
hasBG: !!this.BG_node,
|
hasBG: !!this.BG_node,
|
||||||
hasPoolLv: !!this.pool_lv_node,
|
|
||||||
hasLvl: !!this.lvl_node,
|
hasLvl: !!this.lvl_node,
|
||||||
bgChildren: this.BG_node?.children.map(c => c.name) || [],
|
|
||||||
poolChildren: this.pool_lv_node?.children.map(c => c.name) || [],
|
|
||||||
nodeActive: this.node.active,
|
nodeActive: this.node.active,
|
||||||
nodeScale: this.node.scale.toString(),
|
nodeScale: this.node.scale.toString(),
|
||||||
nodePos: this.node.position.toString(),
|
nodePos: this.node.position.toString(),
|
||||||
@@ -242,13 +237,6 @@ export class CardLiteComp extends CCComp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const cardLvStr = `lv${this.cardData.pool_lv}`;
|
|
||||||
if (this.pool_lv_node) {
|
|
||||||
this.pool_lv_node.children.forEach(child => {
|
|
||||||
child.active = (child.name === cardLvStr);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.card_type === CardType.Hero) {
|
if (this.card_type === CardType.Hero) {
|
||||||
const hero = HeroInfo[this.card_uuid];
|
const hero = HeroInfo[this.card_uuid];
|
||||||
const heroLv = Math.max(1, this.cardData.hero_lv ?? hero?.lv ?? 1);
|
const heroLv = Math.max(1, this.cardData.hero_lv ?? hero?.lv ?? 1);
|
||||||
@@ -317,10 +305,12 @@ export class CardLiteComp extends CCComp {
|
|||||||
}
|
}
|
||||||
if (this.lvl_node) this.lvl_node.node.active = false;
|
if (this.lvl_node) this.lvl_node.node.active = false;
|
||||||
if (this.BG_node) {
|
if (this.BG_node) {
|
||||||
this.BG_node.children.forEach(child => child.active = false);
|
this.BG_node.children.forEach(child => {
|
||||||
}
|
child.active = false;
|
||||||
if (this.pool_lv_node) {
|
child.children.forEach(colorChild => {
|
||||||
this.pool_lv_node.children.forEach(child => child.active = false);
|
colorChild.active = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (this.icon_node) {
|
if (this.icon_node) {
|
||||||
(this.icon_node as Node).setScale(new Vec3(1, 1, 1));
|
(this.icon_node as Node).setScale(new Vec3(1, 1, 1));
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ export class HInfoComp extends CCComp {
|
|||||||
@property(Label)
|
@property(Label)
|
||||||
lv_node: Label = null!
|
lv_node: Label = null!
|
||||||
|
|
||||||
@property(Node)
|
|
||||||
pool_lvnode: Node = null!
|
|
||||||
@property(Node)
|
@property(Node)
|
||||||
ap_node=null!
|
ap_node=null!
|
||||||
|
|
||||||
@@ -160,13 +158,6 @@ export class HInfoComp extends CCComp {
|
|||||||
this.lv_node.color = getLvColor(heroLv);
|
this.lv_node.color = getLvColor(heroLv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pool_lvnode) {
|
|
||||||
const poolLvStr = `lv${this.previewPoolLv}`;
|
|
||||||
this.pool_lvnode.children.forEach(child => {
|
|
||||||
child.active = (child.name === poolLvStr);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
||||||
const poolColorIdx = Math.min(this.previewPoolLv, 5) - 1;
|
const poolColorIdx = Math.min(this.previewPoolLv, 5) - 1;
|
||||||
const activeColor = poolColorNames[poolColorIdx];
|
const activeColor = poolColorNames[poolColorIdx];
|
||||||
@@ -288,16 +279,8 @@ export class HInfoComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- 卡池等级标识 ----
|
// ---- 卡池等级标识 ----
|
||||||
const poolLv = this.model.pool_lv ?? 1;
|
|
||||||
if (this.pool_lvnode) {
|
|
||||||
const poolLvStr = `lv${poolLv}`;
|
|
||||||
this.pool_lvnode.children.forEach(child => {
|
|
||||||
child.active = (child.name === poolLvStr);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
||||||
const poolColorIdx = Math.min(poolLv, 5) - 1;
|
const poolColorIdx = Math.min(this.model.pool_lv ?? 1, 5) - 1;
|
||||||
const activeColor = poolColorNames[poolColorIdx];
|
const activeColor = poolColorNames[poolColorIdx];
|
||||||
const kindName = CKind[CKind.Hero];
|
const kindName = CKind[CKind.Hero];
|
||||||
if (this.BG_node) {
|
if (this.BG_node) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { oops } from "db://oops-framework/core/Oops";
|
|||||||
import { mLogger } from "../common/Logger";
|
import { mLogger } from "../common/Logger";
|
||||||
import { HeroInfo, HeroList } from "../common/config/heroSet";
|
import { HeroInfo, HeroList } from "../common/config/heroSet";
|
||||||
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
|
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
|
||||||
|
import { CKind } from "../common/config/CardSet";
|
||||||
import { CardLiteComp } from "./CardLiteComp";
|
import { CardLiteComp } from "./CardLiteComp";
|
||||||
|
|
||||||
const { property, ccclass } = _decorator;
|
const { property, ccclass } = _decorator;
|
||||||
@@ -45,6 +46,10 @@ export class HerosListComp extends CCComp {
|
|||||||
@property(Node)
|
@property(Node)
|
||||||
cd_node = null!
|
cd_node = null!
|
||||||
|
|
||||||
|
/** 卡牌背景底框节点(按卡池等级切换子节点显示) */
|
||||||
|
@property(Node)
|
||||||
|
BG_node=null!
|
||||||
|
|
||||||
@property(Node)
|
@property(Node)
|
||||||
info_node = null!
|
info_node = null!
|
||||||
|
|
||||||
@@ -199,11 +204,32 @@ export class HerosListComp extends CCComp {
|
|||||||
if (infoLabel) infoLabel.string = desc || hero.info || ""
|
if (infoLabel) infoLabel.string = desc || hero.info || ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.updatePoolLvBg(hero.pool_lv ?? 1)
|
||||||
this.updateLvDisplay(hero)
|
this.updateLvDisplay(hero)
|
||||||
this.updateTypeDisplay(hero)
|
this.updateTypeDisplay(hero)
|
||||||
this.updateHeroAnimation(uuid)
|
this.updateHeroAnimation(uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updatePoolLvBg(poolLv: number) {
|
||||||
|
if (!this.BG_node) return
|
||||||
|
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
||||||
|
const poolColorIdx = Math.min(poolLv, 5) - 1;
|
||||||
|
const activeColor = poolColorNames[poolColorIdx];
|
||||||
|
const kindName = CKind[CKind.Hero];
|
||||||
|
this.BG_node.children.forEach(child => {
|
||||||
|
child.active = (child.name === kindName);
|
||||||
|
if (child.active) {
|
||||||
|
child.children.forEach(colorChild => {
|
||||||
|
colorChild.active = (colorChild.name === activeColor);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
child.children.forEach(colorChild => {
|
||||||
|
colorChild.active = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private updateCdDisplay(hero: typeof HeroInfo[number]) {
|
private updateCdDisplay(hero: typeof HeroInfo[number]) {
|
||||||
if (!this.cd_node) return
|
if (!this.cd_node) return
|
||||||
const skillKeys = Object.keys(hero.skills)
|
const skillKeys = Object.keys(hero.skills)
|
||||||
|
|||||||
Reference in New Issue
Block a user