重构(地图卡牌): 抽离技能卡牌逻辑为独立组件

- 新增SCardComp.ts,实现技能卡牌专属的UI渲染、点击交互与使用逻辑
- 更新MissionCardComp.ts,替换技能卡槽的组件类型为SCardComp并修正相关代码
- 重构CardComp.ts:移除所有Skill类型卡牌的处理代码,修复卡牌等级取值优先级问题,简化拖拽逻辑仅保留英雄卡上划使用功能
This commit is contained in:
panFD
2026-06-04 19:08:54 +08:00
parent 2276ff1fbd
commit 237df1dc4e
6 changed files with 21246 additions and 1930 deletions

View File

@@ -298,7 +298,7 @@ export class CardComp extends CCComp {
reason: "",
uuid: this.cardData.uuid,
hero_lv: this.cardData.hero_lv ?? 1,
card_lv: this.cardData.pool_lv ?? 1
card_lv: this.cardData.base_pool_lv ?? this.cardData.pool_lv ?? 1
};
oops.message.dispatchEvent(GameEvent.UseHeroCard, guard);
if (guard.cancel) {
@@ -355,9 +355,6 @@ export class CardComp extends CCComp {
case CardType.Hero:
oops.message.dispatchEvent(GameEvent.CallHero, payload);
break;
case CardType.Skill:
oops.message.dispatchEvent(GameEvent.UseSkillCard, payload);
break;
case CardType.SpecialUpgrade:
case CardType.SpecialRefresh:
oops.message.dispatchEvent(GameEvent.UseSpecialCard, payload);
@@ -507,10 +504,7 @@ export class CardComp extends CCComp {
}
}
// 技能卡不支持上划移动
if (this.cardData.type !== CardType.Skill) {
this.node.setPosition(this.restPosition.x, this.restPosition.y + deltaY, this.restPosition.z);
}
this.node.setPosition(this.restPosition.x, this.restPosition.y + deltaY, this.restPosition.z);
}
/**
@@ -533,24 +527,13 @@ export class CardComp extends CCComp {
oops.gui.remove(UIID.HInfo);
}
// 技能卡改为点击使用
if (this.cardData.type === CardType.Skill) {
if (Math.abs(deltaY) < 20 && Math.abs(deltaX) < 20) {
const used = this.useCard();
if (!used) {
this.playReboundAnim();
}
return;
}
} else {
// 英雄卡保持上划使用
if (deltaY >= this.dragUseThreshold) {
const used = this.useCard();
if (!used) {
this.playReboundAnim();
}
return;
// 英雄卡保持上划使用
if (deltaY >= this.dragUseThreshold) {
const used = this.useCard();
if (!used) {
this.playReboundAnim();
}
return;
}
this.playReboundAnim();
@@ -722,19 +705,6 @@ export class CardComp extends CCComp {
this.hp_node.active = true;
// 英雄卡:隐藏技能信息节点
if (this.info_node) this.info_node.active = false;
} else if (this.card_type === CardType.Skill) {
if (this.lvl_node) this.lvl_node.node.active = false;
// 技能卡:显示技能名 + 品质后缀 + 描述
const skill = SkillSet[this.card_uuid];
const skillCard = CardPoolList.find(c => c.uuid === this.card_uuid);
const card_lv = Math.max(1, Math.floor(this.cardData.card_lv ?? 1));
const spSuffix = card_lv >= 2 ? "★".repeat(card_lv - 1) : "";
this.setLabel(this.name_node, `${spSuffix}${skillCard?.name || skill?.name || ""}${spSuffix}`);
this.ap_node.active = false;
this.hp_node.active = false;
// 技能卡:显示技能信息节点
if (this.info_node) this.info_node.active = true;
} else {
if (this.lvl_node) this.lvl_node.node.active = false;
// 特殊卡(升级 / 刷新):显示卡名 + 品质后缀 + 描述
@@ -758,11 +728,6 @@ export class CardComp extends CCComp {
}
}
if (this.name_node) {
const currentPos = this.name_node.position;
this.name_node.setPosition(currentPos.x, -70, currentPos.z);
}
// ---- 图标 ----
const iconNode = this.icon_node as Node;
if (this.card_type === CardType.Hero) {
@@ -880,10 +845,6 @@ export class CardComp extends CCComp {
});
});
if (this.name_node) {
const currentPos = this.name_node.position;
this.name_node.setPosition(currentPos.x, -70, currentPos.z);
}
this.iconVisualToken += 1;
this.setLabel(this.name_node, "");
if (this.cost_node) {
@@ -936,9 +897,6 @@ export class CardComp extends CCComp {
* @returns 图标帧名称
*/
private resolveCardIconId(type: CardType, uuid: number): string {
if (type === CardType.Skill) {
return SkillSet[uuid]?.icon || `${uuid}`;
}
if (type === CardType.Hero) {
return HeroInfo[uuid]?.icon || `${uuid}`;
}