refactor: 重构技能弹窗系统,移除冗余技能池逻辑
1. 删除SkillBoxCardConfig相关类型、技能池配置和抽卡函数 2. 移除技能弹窗的刷新次数持久化逻辑与UI 3. 简化MissSkillsComp、SkillBoxComp的技能处理流程 4. 统一技能卡的添加和初始化逻辑,移除config专用初始化流程 5. 调整MissionCardComp的波次技能弹窗触发逻辑 6. 清理CardComp中冗余的技能描述缓存代码 7. 修正UIConfig中SkillBox预制体路径命名
This commit is contained in:
@@ -28,7 +28,6 @@ import { SkillBoxComp } from "./SkillBoxComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { SkillBoxCardConfig } from "../common/config/CardSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 技能槽位数据结构 */
|
||||
@@ -142,32 +141,13 @@ export class MissSkillsComp extends CCComp {
|
||||
* 处理使用技能卡事件:提取 uuid 和 card_lv 后调用 addSkill。
|
||||
* @param event 事件名
|
||||
* @param args 卡牌数据(含 uuid、card_lv)
|
||||
*
|
||||
* 兼容两种数据源:
|
||||
* - 普通卡池(uuid < 9000):走 addSkill(uuid, card_lv) 旧流程
|
||||
* - SkillBox 卡池(uuid >= 9000 且 payload 含 s_uuid):
|
||||
* 视为 SkillBoxCardConfig,使用 addSkillByConfig 走新流程
|
||||
*/
|
||||
private onUseSkillCard(event: string, args: any) {
|
||||
const payload = args ?? event;
|
||||
const uuid = Number(payload?.uuid ?? 0);
|
||||
const card_lv = Math.max(1, Math.floor(Number(payload?.card_lv ?? 1)));
|
||||
if (!uuid) return;
|
||||
if (this.isSkillBoxPayload(payload)) {
|
||||
this.addSkillByConfig(payload as SkillBoxCardConfig);
|
||||
} else {
|
||||
this.addSkill(uuid, card_lv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 payload 是否为 SkillBox 三选一弹窗的卡牌配置。
|
||||
* 识别规则:uuid >= 9000 且 payload 含 s_uuid 字段。
|
||||
*/
|
||||
private isSkillBoxPayload(payload: any): boolean {
|
||||
if (!payload) return false;
|
||||
const uuid = Number(payload.uuid ?? 0);
|
||||
return uuid >= 9000 && Number(payload.s_uuid ?? 0) > 0;
|
||||
this.addSkill(uuid, card_lv);
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -212,37 +192,6 @@ export class MissSkillsComp extends CCComp {
|
||||
comp.init(uuid, card_lv);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在场上添加一个 SkillBox 弹窗产出的技能卡(uuid >= 9000):
|
||||
* 流程与 addSkill 相同,但初始化走 initWithConfig 以支持 overrides / s_uuid。
|
||||
*
|
||||
* @param skillBoxCard SkillBoxCardConfig 完整卡牌配置
|
||||
*/
|
||||
addSkillByConfig(skillBoxCard: SkillBoxCardConfig) {
|
||||
var parent = smc.map.MapView.scene.entityLayer!.node!.getChildByName("SKILL")!;
|
||||
|
||||
if (!this.skill_box) {
|
||||
mLogger.error(this.debugMode, "MissSkillsComp", "skill_box prefab not set");
|
||||
return;
|
||||
}
|
||||
|
||||
const emptyIndex = this.slots.findIndex(slot => !slot.used);
|
||||
if (emptyIndex === -1) {
|
||||
mLogger.warn(this.debugMode, "MissSkillsComp", "skill_box slots are full");
|
||||
return;
|
||||
}
|
||||
|
||||
const node = instantiate(this.skill_box);
|
||||
node.parent = parent;
|
||||
node.setPosition(new Vec3(this.slots[emptyIndex].x, this.slots[emptyIndex].y, 0));
|
||||
|
||||
this.slots[emptyIndex].used = true;
|
||||
this.slots[emptyIndex].node = node;
|
||||
|
||||
const comp = node.getComponent(SkillBoxComp) || node.addComponent(SkillBoxComp);
|
||||
comp.initWithConfig(skillBoxCard);
|
||||
}
|
||||
|
||||
/** ECS 组件移除时销毁节点 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user