feat(map): 新增固定波次技能三选一弹窗系统
1. 新增MSkillBoxComp弹窗组件,实现固定波次触发的技能卡选择功能 2. 新增SkillBoxCardConfig配置与SkillBoxPool技能池,支持按波次配置技能 3. 重构MissionCardComp,将技能卡抽取改为固定波次弹窗触发 4. 扩展SingletonModuleComp与MissionComp,添加技能刷新次数持久化逻辑 5. 优化MissSkillsComp,新增SkillBox专属技能加载流程 6. 修复SkillBoxComp,支持自定义技能参数覆盖 7. 调整UIConfig与CardSet配置,适配新的技能卡流程
This commit is contained in:
@@ -28,6 +28,7 @@ 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;
|
||||
|
||||
/** 技能槽位数据结构 */
|
||||
@@ -55,7 +56,7 @@ export class MissSkillsComp extends CCComp {
|
||||
private debugMode: boolean = true;
|
||||
|
||||
/** 技能卡 Prefab(在编辑器中赋值) */
|
||||
@property({type: Prefab})
|
||||
@property({ type: Prefab })
|
||||
private skill_box: Prefab = null;
|
||||
|
||||
/**
|
||||
@@ -67,13 +68,13 @@ export class MissSkillsComp extends CCComp {
|
||||
{ x: -320, y: 240, used: false, node: null },
|
||||
{ x: -240, y: 240, used: false, node: null },
|
||||
{ x: -160, y: 240, used: false, node: null },
|
||||
{ x: -80, y: 240, used: false, node: null },
|
||||
{ x: 0, y: 240, used: false, node: null },
|
||||
{ x: -80, y: 240, used: false, node: null },
|
||||
{ x: 0, y: 240, used: false, node: null },
|
||||
{ x: -320, y: 320, used: false, node: null },
|
||||
{ x: -240, y: 320, used: false, node: null },
|
||||
{ x: -160, y: 320, used: false, node: null },
|
||||
{ x: -80, y: 320, used: false, node: null },
|
||||
{ x: 0, y: 320, used: false, node: null },
|
||||
{ x: -80, y: 320, used: false, node: null },
|
||||
{ x: 0, y: 320, used: false, node: null },
|
||||
];
|
||||
|
||||
/** 注册事件监听 */
|
||||
@@ -141,17 +142,36 @@ 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;
|
||||
this.addSkill(uuid, card_lv);
|
||||
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;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +186,7 @@ export class MissSkillsComp extends CCComp {
|
||||
addSkill(uuid: number, card_lv: number) {
|
||||
// 技能节点的父容器
|
||||
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;
|
||||
@@ -183,7 +203,7 @@ export class MissSkillsComp extends CCComp {
|
||||
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;
|
||||
|
||||
@@ -192,6 +212,37 @@ 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