refactor(config): 将CardKind枚举移动到GameSet并更新相关引用
重构代码结构,将CardKind枚举从CardSet.ts移动到GameSet.ts以集中管理游戏配置枚举 更新MissionCardComp.ts中的卡片类型显示逻辑,支持根据CardKind动态显示对应节点 调整card.prefab的UI元素位置和尺寸,优化卡片显示效果
This commit is contained in:
@@ -4,7 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { CardType, FightSet } from "../common/config/GameSet";
|
||||
import { CardType, FightSet, CardKind } from "../common/config/GameSet";
|
||||
import { getCardOptions, ICardInfo } from "../common/config/CardSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -301,6 +301,65 @@ export class MissionCardComp extends CCComp {
|
||||
// ICardInfo 已经标准化了 desc,直接使用
|
||||
info.getComponent(Label)!.string = data.desc || "";
|
||||
}
|
||||
|
||||
// 先隐藏所有类型标识
|
||||
const typeNodes = ["Atk", "Atked", "Buff", "Attr", "Skill", "Hp", "Dead", "Partner"];
|
||||
|
||||
// 1. 处理 card 直接子节点
|
||||
typeNodes.forEach(nodeName => {
|
||||
const node = card.getChildByName(nodeName);
|
||||
if (node) node.active = false;
|
||||
});
|
||||
|
||||
// 2. 处理 card/type 下的子节点
|
||||
const typeContainer = card.getChildByName("type");
|
||||
if (typeContainer) {
|
||||
typeNodes.forEach(nodeName => {
|
||||
const node = typeContainer.getChildByName(nodeName);
|
||||
if (node) node.active = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 根据 kind 激活对应节点
|
||||
let activeNodeName = "";
|
||||
switch (data.kind) {
|
||||
case CardKind.Atk:
|
||||
activeNodeName = "Atk";
|
||||
break;
|
||||
case CardKind.Atted:
|
||||
activeNodeName = "Atked";
|
||||
break;
|
||||
case CardKind.Buff:
|
||||
activeNodeName = "Buff";
|
||||
break;
|
||||
case CardKind.Attr:
|
||||
activeNodeName = "Attr";
|
||||
break;
|
||||
case CardKind.Skill:
|
||||
activeNodeName = "Skill";
|
||||
break;
|
||||
case CardKind.Hp:
|
||||
activeNodeName = "Hp";
|
||||
break;
|
||||
case CardKind.Dead:
|
||||
activeNodeName = "Dead";
|
||||
break;
|
||||
case CardKind.Partner:
|
||||
activeNodeName = "Partner";
|
||||
break;
|
||||
}
|
||||
|
||||
if (activeNodeName) {
|
||||
// 激活 card 下的节点
|
||||
const activeNode = card.getChildByName(activeNodeName);
|
||||
if (activeNode) activeNode.active = true;
|
||||
|
||||
// 激活 card/type 下的节点
|
||||
if (typeContainer) {
|
||||
const activeTypeNode = typeContainer.getChildByName(activeNodeName);
|
||||
if (activeTypeNode) activeTypeNode.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateCardData(index: number, data: ICardInfo) {
|
||||
|
||||
Reference in New Issue
Block a user