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)
cards_node:Node = null!
cards_node: Node = null!
/** 卡牌槽位 1 节点 */
@property(Node)
card1:Node = null!
card1: Node = null!
/** 卡牌槽位 2 节点 */
@property(Node)
card2:Node = null!
card2: Node = null!
/** 卡牌槽位 3 节点 */
@property(Node)
card3:Node = null!
card3: Node = null!
/** 卡牌槽位 4 节点 */
@property(Node)
card4:Node = null!
card4: Node = null!
/** 抽卡(刷新)按钮节点 */
@property(Node)
cards_chou:Node = null!
cards_chou: Node = null!
/** 卡池升级按钮节点 */
@property(Node)
cards_up:Node = null!
cards_up: Node = null!
/** 金币显示节点(含 icon + num 子节点) */
@property(Node)
coins_node:Node = null!
coins_node: Node = null!
/** 卡池等级显示节点 */
@property(Node)
pool_lv_node:Node = null!
pool_lv_node: Node = null!
/** 英雄数量显示节点(含 icon + num 子节点) */
@property(Node)
hero_num_node:Node=null!
hero_num_node: Node = null!
// ======================== 运行时状态 ========================
@@ -128,7 +128,7 @@ export class MissionCardComp extends CCComp {
/** 卡牌面板收起态缩放scale=0 隐藏) */
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 调用) */
init(){
init() {
this.onMissionStart();
}
@@ -276,7 +276,7 @@ export class MissionCardComp extends CCComp {
* 金币变化事件回调:
* 仅负责 UI 更新和动画表现。数据更新已由 MissionEconomy 统一处理。
*/
private onCoinAdd(event: string, args: any){
private onCoinAdd(event: string, args: any) {
const payload = args ?? event;
const v = typeof payload === 'number' ? payload : (payload?.delta ?? payload?.value ?? 0);
this.updateCoinAndCostUI();
@@ -448,7 +448,7 @@ export class MissionCardComp extends CCComp {
* @returns { needCount: 合成所需数量, maxLv: 最大合成等级 }
*/
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));
ecs.query(ecs.allOf(MissionHeroComp)).forEach((entity: ecs.Entity) => {
const comp = entity.get(MissionHeroComp);
@@ -765,16 +765,13 @@ export class MissionCardComp extends CCComp {
if (this.pool_lv_node) {
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 poolLvStr = `lv${lv}`;
this.pool_lv_node.children.forEach(child => {
if (child.name === "light") {
child.active = false;
} else if (child.name === "bg") {
child.active = true;
} else {
child.active = (child.name === poolLvStr);
const lvNode = this.pool_lv_node.getChildByName("lv");
if (lvNode) {
const label = lvNode.getComponent(Label);
if (label) {
label.string = `lv.${lv}`;
}
}
});
const widget = this.pool_lv_node.getComponent(Widget);
if (widget) widget.updateAlignment();
this.pool_lv_node.children.forEach(child => {
@@ -782,7 +779,7 @@ export class MissionCardComp extends CCComp {
if (childWidget) childWidget.updateAlignment();
});
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", {
poolLv: this.poolLv,
@@ -811,10 +808,10 @@ export class MissionCardComp extends CCComp {
private playCoinChangeAnim(isIncrease: boolean) {
if (!this.coins_node || !this.coins_node.isValid) return;
const icon = this.coins_node.getChildByName("icon");
if (!icon || !icon.isValid ) return;
if (!icon || !icon.isValid) return;
const peak = isIncrease ? 1.2 : 1.2;
this.playHeroNumNodePop(icon, peak);
const num= this.coins_node.getChildByName("num");
const num = this.coins_node.getChildByName("num");
if (!num || !num.isValid) return;
this.playHeroNumNodePop(num, peak);
}
@@ -854,7 +851,7 @@ export class MissionCardComp extends CCComp {
let count = 0;
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
const model = entity.get(HeroAttrsComp);
if (model && model.fac === FacSet.HERO ) {
if (model && model.fac === FacSet.HERO) {
count++;
}
});