67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { BoxSet } from "../common/config/BoxSet";
|
|
import { SkillSet } from "../common/config/SkillSet";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { SkillCom } from "./SkillCom";
|
|
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
|
|
|
/** Skill 模块 */
|
|
@ecs.register(`Skill`)
|
|
export class Skill extends ecs.Entity {
|
|
|
|
SkillView!: SkillCom;
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
|
|
}
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
this.remove(SkillCom);
|
|
super.destroy();
|
|
}
|
|
load(
|
|
startPos: Vec3, // 起始位置
|
|
group: number, // 阵营
|
|
parent: Node, // 父节点
|
|
uuid: number, // 技能ID
|
|
targetPos: Vec3, // 目标位置
|
|
target:any=null, // 目标
|
|
caster:any=null // 施法者
|
|
) {
|
|
const config = SkillSet[uuid];
|
|
if (!config) return;
|
|
|
|
// 加载预制体
|
|
const path = `game/skills/${config.sp_name}`;
|
|
const prefab = oops.res.get(path, Prefab);
|
|
const node = instantiate(prefab);
|
|
|
|
// 设置节点属性
|
|
node.parent = parent;
|
|
node.setPosition(startPos);
|
|
console.log("加载预制体:",startPos,targetPos)
|
|
// 添加技能组件
|
|
const skillComp = node.getComponent(SkillCom); // 初始化技能参数
|
|
skillComp.s_uuid = uuid;
|
|
skillComp.animType = config.AnimType;
|
|
skillComp.endType = config.endType;
|
|
skillComp.speed = config.speed;
|
|
skillComp.inTime = config.in;
|
|
skillComp.atk_count = 0;
|
|
skillComp.startPos = v3(startPos.x,BoxSet.GAME_LINE+35,0)
|
|
skillComp.targetPos = v3(targetPos.x,BoxSet.GAME_LINE+50,0)
|
|
skillComp.target = target;
|
|
skillComp.caster = caster;
|
|
skillComp.prefabName = config.sp_name;
|
|
skillComp.group = group;
|
|
console.log(config.sp_name+"技能配置",skillComp);
|
|
// 初始化动画名称
|
|
skillComp.animName = config.animName; // 从配置获取动画名称
|
|
this.add(skillComp);
|
|
|
|
|
|
}
|
|
}
|