92 lines
3.4 KiB
TypeScript
92 lines
3.4 KiB
TypeScript
import { instantiate, Node, Prefab, v3, Vec3 } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
|
|
import { oops } from "db://oops-framework/core/Oops";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { FacSet } from "../common/config/BoxSet";
|
|
import { HType } from "../common/config/heroSet";
|
|
import { SkillViewCom } from "./SkillViewCom";
|
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
|
|
|
/** SkillCon 模块 */
|
|
@ecs.register(`SkillEnt`)
|
|
export class SkillEnt extends ecs.Entity {
|
|
|
|
load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:HeroViewComp=null,dmg:number=0) {
|
|
const config = SkillSet[uuid];
|
|
if (!config) {
|
|
console.error("[Skill] 技能配置不存在:", uuid);
|
|
return;
|
|
}
|
|
// 检查施法者
|
|
if (!caster) {
|
|
console.error("[Skill] 施法者为空");
|
|
return;
|
|
}
|
|
// 加载预制体
|
|
const path = `game/skill/atk/${config.sp_name}`;
|
|
const prefab:Prefab = oops.res.get(path, Prefab);
|
|
if (!prefab) {
|
|
console.error("[Skill] 预制体加载失败:", path);
|
|
return;
|
|
}
|
|
if(uuid==6001){
|
|
console.log("load skill startPos",startPos)
|
|
}
|
|
const node: Node = instantiate(prefab);
|
|
node.parent = parent;
|
|
// 设置节点属性
|
|
node.setPosition(startPos);
|
|
if(caster.fac==FacSet.MON){
|
|
node.scale=v3(node.scale.x*-1,1,1)
|
|
}else{
|
|
if(caster.type==HType.warrior){
|
|
if(caster.node.scale.x<0){
|
|
node.scale=v3(node.scale.x*-1,node.scale.y,1)
|
|
}
|
|
}
|
|
}
|
|
// 添加技能组件
|
|
const SComp = node.getComponent(SkillViewCom); // 初始化技能参数
|
|
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
|
|
Object.assign(SComp, {
|
|
// 核心标识
|
|
s_uuid: uuid,
|
|
// 位置和施法者信息
|
|
startPos: startPos,
|
|
targetPos: targetPos,
|
|
group: caster.box_group,
|
|
fac: caster.fac,
|
|
// 技能数值
|
|
ap: caster.Attrs[BuffAttr.AP],
|
|
caster: caster,
|
|
caster_crit: caster.Attrs[BuffAttr.CRITICAL],
|
|
caster_crit_d: caster.Attrs[BuffAttr.CRITICAL_DMG],
|
|
puncture: caster.Attrs[BuffAttr.PUNCTURE],
|
|
puncture_damage: caster.Attrs[BuffAttr.PUNCTURE_DMG],
|
|
burn_count: caster.Attrs[BuffAttr.BURN_COUNT],
|
|
burn_value: caster.Attrs[BuffAttr.BURN_VALUE],
|
|
stun_time: caster.Attrs[BuffAttr.STUN_TIME],
|
|
stun_ratio: caster.Attrs[BuffAttr.STUN_RATIO],
|
|
frost_time: caster.Attrs[BuffAttr.FROST_TIME],
|
|
frost_ratio: caster.Attrs[BuffAttr.FROST_RATIO],
|
|
debuff_up: caster.Attrs[BuffAttr.DEBUFF_UP],
|
|
debuff_value: caster.Attrs[BuffAttr.DEBUFF_VALUE],
|
|
debuff_count: caster.Attrs[BuffAttr.DEBUFF_COUNT],
|
|
});
|
|
this.add(SComp);
|
|
}
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
// this.addComponents<ecs.Comp>();
|
|
}
|
|
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
this.remove(SkillViewCom);
|
|
super.destroy();
|
|
}
|
|
}
|