refactor: 清理废弃资源并优化卡牌相关逻辑

1.  删除废弃的notify.prefab和TalentSet.ts.meta文件
2.  新增MSkillBox预制体资源
3.  优化MissionCardComp抽卡按钮显示逻辑
4.  格式化CardComp.ts代码格式与变量声明
5.  优化MissionComp.ts代码格式与事件绑定
6.  更新mission.prefab布局添加技能槽位
This commit is contained in:
pan
2026-06-03 14:39:31 +08:00
parent 15c771c58c
commit 55c277016d
10 changed files with 6228 additions and 1565 deletions

View File

@@ -67,19 +67,22 @@ export class CardComp extends CCComp {
// info_node=null!
/** 卡牌名称标签节点 */
@property(Node)
name_node=null!
name_node = null!
/** 卡牌图标节点(英雄动画 / 技能图标) */
@property(Node)
icon_node=null!
icon_node = null!
/** 费用显示节点 */
@property(Node)
cost_node=null!
cost_node = null!
/** 卡牌种类标识节点(如近战 / 远程 / 辅助等分类子节点的容器) */
@property(Node)
Ckind_node=null!
Ckind_node = null!
/** 卡牌背景底框节点(按卡池等级切换子节点显示) */
@property(Node)
BG_node=null!
BG_node = null!
/** 技能卡牌信息节点,显示技能信息*/
@property(Node)
info_node = null!
@@ -87,18 +90,18 @@ export class CardComp extends CCComp {
lvl_node: Label = null! //英雄本身的等级
@property(Node)
ap_node=null!
ap_node = null!
@property(Node)
hp_node=null!
hp_node = null!
// ======================== 运行时状态 ========================
/** 当前卡牌的金币费用 */
card_cost:number=0
card_cost: number = 0
/** 当前卡牌类型(英雄 / 技能 / 特殊升级 / 特殊刷新) */
card_type:CardType=CardType.Hero
card_type: CardType = CardType.Hero
/** 当前卡牌的唯一标识 UUID */
card_uuid:number=0
card_uuid: number = 0
/** 是否处于锁定状态(锁定且有卡时,抽卡分发会被跳过) */
private isLocked: boolean = false;
/** 当前槽位承载的卡牌数据null 表示空槽 */
@@ -148,7 +151,7 @@ export class CardComp extends CCComp {
this.applyEmptyUI();
}
/** 组件销毁时解绑所有事件,防止残留回调 */
onDestroy() {
super.onDestroy();
@@ -156,18 +159,18 @@ export class CardComp extends CCComp {
}
/** 外部初始化入口(由 MissionCardComp 调用) */
init(){
init() {
this.onMissionStart();
}
/** 游戏开始初始化(预留扩展) */
onMissionStart() {
}
/** 游戏结束清理(预留扩展) */
onMissionEnd() {
}
/** 节点启动时确保可见 */
@@ -183,7 +186,7 @@ export class CardComp extends CCComp {
* @param card 卡牌节点引用(历史遗留参数,当前未使用)
* @param data 卡牌配置数据
*/
updateCardInfo(card:Node, data: CardConfig){
updateCardInfo(card: Node, data: CardConfig) {
this.applyDrawCard(data);
}
@@ -218,13 +221,13 @@ export class CardComp extends CCComp {
* @param index 索引字符串(历史遗留参数)
*/
selectCard(e: any, index: string) {
this.useCard();
this.useCard();
}
/** 关闭界面(预留) */
close() {
}
// ======================== 核心业务方法 ========================
@@ -285,7 +288,7 @@ export class CardComp extends CCComp {
useCard(): CardConfig | null {
if (!this.cardData || this.isUsing) return null;
const cardCost = this.card_cost;
// 英雄卡特殊校验:通过 guard 对象实现"可取消"模式
if (this.cardData.type === CardType.Hero) {
const guard = {
@@ -318,7 +321,7 @@ export class CardComp extends CCComp {
// 【评分系统 - 效率分】记录刷新后的选中卡次数(命中率分子)
smc.vmdata.scores.refresh_hit_count++;
// 标记使用中,阻止并发操作
this.isUsing = true;
const used = this.cardData;
@@ -359,7 +362,7 @@ export class CardComp extends CCComp {
break;
}
}
/** 查询槽位是否有卡 */
hasCard(): boolean {
return !!this.cardData;
@@ -519,7 +522,7 @@ export class CardComp extends CCComp {
this.isLongPressed = false;
oops.gui.remove(UIID.HInfo);
}
if (deltaY >= this.dragUseThreshold) {
const used = this.useCard();
if (!used) {
@@ -527,7 +530,7 @@ export class CardComp extends CCComp {
}
return;
}
this.playReboundAnim();
}
@@ -602,9 +605,9 @@ export class CardComp extends CCComp {
// 递增视觉令牌,用于异步加载竞态保护
this.iconVisualToken += 1;
if (this.opacityComp) this.opacityComp.opacity = 255;
this.node.setPosition(this.restPosition.x, this.restPosition.y, this.restPosition.z);
// ---- 卡牌种类标识(近战 / 远程 / 辅助等) ----
const kindName = CKind[this.cardData.kind];
@@ -633,7 +636,7 @@ export class CardComp extends CCComp {
const widget = this.node.getComponent(Widget);
if (widget) widget.updateAlignment();
}
if (this.BG_node) {
const bgTrans = this.BG_node.getComponent(UITransform);
if (bgTrans) {
@@ -650,7 +653,7 @@ export class CardComp extends CCComp {
}
});
}
const hbNode = this.node.getChildByName("HB");
if (hbNode) {
const hbTrans = hbNode.getComponent(UITransform);
@@ -660,7 +663,7 @@ export class CardComp extends CCComp {
if (widget) widget.updateAlignment();
}
}
// 触发布局刷新确保其所有子节点比如右上角的cost、名字等依赖 Widget 的节点重新对齐
this.node.children.forEach(child => {
const widget = child.getComponent(Widget);
@@ -680,7 +683,7 @@ export class CardComp extends CCComp {
if (widget) widget.updateAlignment();
}
if(this.card_type===CardType.Hero){
if (this.card_type === CardType.Hero) {
const hero = HeroInfo[this.card_uuid];
const heroLv = Math.max(1, this.cardData.hero_lv ?? hero?.lv ?? 1);
this.setLabel(this.name_node, `${hero?.name || ""}`);
@@ -691,11 +694,11 @@ export class CardComp extends CCComp {
}
this.ap_node.getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
this.hp_node.getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
this.ap_node.active = true;
this.hp_node.active = true;
}else if(this.card_type===CardType.Skill){
} else if (this.card_type === CardType.Skill) {
if (this.lvl_node) this.lvl_node.node.active = false;
// 技能卡:显示技能名 + 品质后缀 + 描述
const skill = SkillSet[this.card_uuid];
@@ -706,7 +709,7 @@ export class CardComp extends CCComp {
this.ap_node.active = false;
this.hp_node.active = false;
}else{
} else {
if (this.lvl_node) this.lvl_node.node.active = false;
// 特殊卡(升级 / 刷新):显示卡名 + 品质后缀 + 描述
const specialCard = this.card_type === CardType.SpecialUpgrade
@@ -728,7 +731,7 @@ export class CardComp extends CCComp {
this.setLabel(numNode, `${this.card_cost}`);
}
}
if (this.name_node) {
const currentPos = this.name_node.position;
this.name_node.setPosition(currentPos.x, -70, currentPos.z);
@@ -841,7 +844,7 @@ export class CardComp extends CCComp {
if (widget) widget.updateAlignment();
}
}
this.node.children.forEach(child => {
const widget = child.getComponent(Widget);
if (widget) widget.updateAlignment();