- 新增 mskills.prefab 作为任务技能容器 - 将 MissSkillsComp 挂载到场景实体层,移除 MissionCardComp 中的引用 - 优化 SkillBoxComp 触发坐标计算,改为基于父节点位置 - 调整技能盒尺寸并添加等级标签显示 - 修复战斗开始时技能触发计时器重置逻辑
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { mLogger } from "../common/Logger";
|
|
import { _decorator, Node, Prefab, instantiate } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
import { SkillBoxComp } from "./SkillBoxComp";
|
|
import { oops } from "db://oops-framework/core/Oops";
|
|
import { GameEvent } from "../common/config/GameEvent";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('MissSkillsComp')
|
|
@ecs.register('MissSkillsComp', false)
|
|
export class MissSkillsComp extends CCComp {
|
|
private debugMode: boolean = true;
|
|
@property({type: Prefab})
|
|
private skill_box: Prefab = null;
|
|
|
|
onLoad() {
|
|
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
|
this.node.parent=smc.map.MapView.scene.entityLayer!.node!
|
|
}
|
|
|
|
onDestroy() {
|
|
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
addSkill(uuid: number, card_lv: number) {
|
|
if (!this.skill_box) {
|
|
mLogger.error(this.debugMode, "MissSkillsComp", "skill_box prefab not set");
|
|
return;
|
|
}
|
|
const node = instantiate(this.skill_box);
|
|
node.parent = this.node;
|
|
const comp = node.getComponent(SkillBoxComp) || node.addComponent(SkillBoxComp);
|
|
comp.init(uuid, card_lv);
|
|
}
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
}
|