style: 优化MissionCardComp代码格式与细节

调整变量类型声明的空格、代码缩进与空行规范,修复部分UI更新逻辑,修正卡牌位置数组的空格格式,统一代码书写风格
This commit is contained in:
pan
2026-05-29 15:30:50 +08:00
parent 62a92ab9b6
commit 8b1f61014b
2 changed files with 1206 additions and 6170 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -81,34 +81,34 @@ export class MissionCardComp extends CCComp {
/** 卡牌面板根节点(战斗阶段收起,准备阶段展开) */ /** 卡牌面板根节点(战斗阶段收起,准备阶段展开) */
@property(Node) @property(Node)
cards_node:Node = null! cards_node: Node = null!
/** 卡牌槽位 1 节点 */ /** 卡牌槽位 1 节点 */
@property(Node) @property(Node)
card1:Node = null! card1: Node = null!
/** 卡牌槽位 2 节点 */ /** 卡牌槽位 2 节点 */
@property(Node) @property(Node)
card2:Node = null! card2: Node = null!
/** 卡牌槽位 3 节点 */ /** 卡牌槽位 3 节点 */
@property(Node) @property(Node)
card3:Node = null! card3: Node = null!
/** 卡牌槽位 4 节点 */ /** 卡牌槽位 4 节点 */
@property(Node) @property(Node)
card4:Node = null! card4: Node = null!
/** 抽卡(刷新)按钮节点 */ /** 抽卡(刷新)按钮节点 */
@property(Node) @property(Node)
cards_chou:Node = null! cards_chou: Node = null!
/** 卡池升级按钮节点 */ /** 卡池升级按钮节点 */
@property(Node) @property(Node)
cards_up:Node = null! cards_up: Node = null!
/** 金币显示节点(含 icon + num 子节点) */ /** 金币显示节点(含 icon + num 子节点) */
@property(Node) @property(Node)
coins_node:Node = null! coins_node: Node = null!
/** 卡池等级显示节点 */ /** 卡池等级显示节点 */
@property(Node) @property(Node)
pool_lv_node:Node = null! pool_lv_node: Node = null!
/** 英雄数量显示节点(含 icon + num 子节点) */ /** 英雄数量显示节点(含 icon + num 子节点) */
@property(Node) @property(Node)
hero_num_node:Node=null! hero_num_node: Node = null!
// ======================== 运行时状态 ======================== // ======================== 运行时状态 ========================
@@ -128,7 +128,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,-75,108,260] private cardsPos = [-260, -75, 108, 260]
// ======================== 生命周期 ======================== // ======================== 生命周期 ========================
@@ -164,7 +164,7 @@ export class MissionCardComp extends CCComp {
} }
/** 外部初始化入口(由 CardController 调用) */ /** 外部初始化入口(由 CardController 调用) */
init(){ init() {
this.onMissionStart(); this.onMissionStart();
} }
@@ -276,7 +276,7 @@ export class MissionCardComp extends CCComp {
* 金币变化事件回调: * 金币变化事件回调:
* 仅负责 UI 更新和动画表现。数据更新已由 MissionEconomy 统一处理。 * 仅负责 UI 更新和动画表现。数据更新已由 MissionEconomy 统一处理。
*/ */
private onCoinAdd(event: string, args: any){ private onCoinAdd(event: string, args: any) {
const payload = args ?? event; const payload = args ?? event;
const v = typeof payload === 'number' ? payload : (payload?.delta ?? payload?.value ?? 0); const v = typeof payload === 'number' ? payload : (payload?.delta ?? payload?.value ?? 0);
this.updateCoinAndCostUI(); this.updateCoinAndCostUI();
@@ -448,7 +448,7 @@ export class MissionCardComp extends CCComp {
* @returns { needCount: 合成所需数量, maxLv: 最大合成等级 } * @returns { needCount: 合成所需数量, maxLv: 最大合成等级 }
*/ */
private getMergeRule(): { needCount: number, maxLv: number } { private getMergeRule(): { needCount: number, maxLv: number } {
let needCount = FightSet.MERGE_NEED ? FightSet.MERGE_NEED:2 let needCount = FightSet.MERGE_NEED ? FightSet.MERGE_NEED : 2
let maxLv = Math.max(1, Math.floor(FightSet.MERGE_MAX ?? 3)); let maxLv = Math.max(1, Math.floor(FightSet.MERGE_MAX ?? 3));
ecs.query(ecs.allOf(MissionHeroComp)).forEach((entity: ecs.Entity) => { ecs.query(ecs.allOf(MissionHeroComp)).forEach((entity: ecs.Entity) => {
const comp = entity.get(MissionHeroComp); const comp = entity.get(MissionHeroComp);
@@ -765,24 +765,21 @@ export class MissionCardComp extends CCComp {
if (this.pool_lv_node) { if (this.pool_lv_node) {
this.pool_lv_node.active = true; this.pool_lv_node.active = true;
const lv = Math.max(CARD_POOL_INIT_LEVEL, Math.min(CARD_POOL_MAX_LEVEL, Math.floor(this.poolLv))); const lv = Math.max(CARD_POOL_INIT_LEVEL, Math.min(CARD_POOL_MAX_LEVEL, Math.floor(this.poolLv)));
const poolLvStr = `lv${lv}`; const lvNode = this.pool_lv_node.getChildByName("lv");
this.pool_lv_node.children.forEach(child => { if (lvNode) {
if (child.name === "light") { const label = lvNode.getComponent(Label);
child.active = false; if (label) {
} else if (child.name === "bg") { label.string = `lv.${lv}`;
child.active = true;
} else {
child.active = (child.name === poolLvStr);
} }
}); }
const widget = this.pool_lv_node.getComponent(Widget); const widget = this.pool_lv_node.getComponent(Widget);
if (widget) widget.updateAlignment(); if (widget) widget.updateAlignment();
this.pool_lv_node.children.forEach(child => { this.pool_lv_node.children.forEach(child => {
const childWidget = child.getComponent(Widget); const childWidget = child.getComponent(Widget);
if (childWidget) childWidget.updateAlignment(); if (childWidget) childWidget.updateAlignment();
}); });
const peak = 1.2 const peak = 1.2
this.playHeroNumNodePop( this.pool_lv_node, peak); this.playHeroNumNodePop(this.pool_lv_node, peak);
} }
mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", { mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", {
poolLv: this.poolLv, poolLv: this.poolLv,
@@ -811,10 +808,10 @@ export class MissionCardComp extends CCComp {
private playCoinChangeAnim(isIncrease: boolean) { private playCoinChangeAnim(isIncrease: boolean) {
if (!this.coins_node || !this.coins_node.isValid) return; if (!this.coins_node || !this.coins_node.isValid) return;
const icon = this.coins_node.getChildByName("icon"); const icon = this.coins_node.getChildByName("icon");
if (!icon || !icon.isValid ) return; if (!icon || !icon.isValid) return;
const peak = isIncrease ? 1.2 : 1.2; const peak = isIncrease ? 1.2 : 1.2;
this.playHeroNumNodePop(icon, peak); this.playHeroNumNodePop(icon, peak);
const num= this.coins_node.getChildByName("num"); const num = this.coins_node.getChildByName("num");
if (!num || !num.isValid) return; if (!num || !num.isValid) return;
this.playHeroNumNodePop(num, peak); this.playHeroNumNodePop(num, peak);
} }
@@ -854,7 +851,7 @@ export class MissionCardComp extends CCComp {
let count = 0; let count = 0;
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => { ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
const model = entity.get(HeroAttrsComp); const model = entity.get(HeroAttrsComp);
if (model && model.fac === FacSet.HERO ) { if (model && model.fac === FacSet.HERO) {
count++; count++;
} }
}); });