59 lines
2.1 KiB
TypeScript
59 lines
2.1 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 {
|
|
/** ---------- 数据层 ---------- */
|
|
// SkillModel!: SkillModelComp;
|
|
|
|
/** ---------- 业务层 ---------- */
|
|
// SkillBll!: SkillBllComp;
|
|
|
|
/** ---------- 视图层 ---------- */
|
|
SkillView!: SkillCom;
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
|
|
}
|
|
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
this.remove(SkillCom);
|
|
super.destroy();
|
|
}
|
|
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,dis:number = 50,scale:number = 1,parent:Node,uuid:number=1001,atk:number =10,angle = 0,t_pos:Vec3 = null) {
|
|
var path = "game/skills/"+smc.skills[uuid].sp_name;
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
// console.log("load skill parent.position :",parent.position)
|
|
pos=v3(parent.position.x+pos.x,parent.position.y+pos.y)
|
|
node.parent = parent.parent;
|
|
node.setScale(scale,1)
|
|
//转换pos为世界坐标
|
|
node.setPosition(pos)
|
|
var sv = node.getComponent(SkillCom)!;
|
|
sv.speed = speed;
|
|
sv.dis = dis;
|
|
sv.scale = scale;
|
|
sv.atk = atk;
|
|
sv.angle = angle;
|
|
sv.t_pos = t_pos; // 目标增量
|
|
sv.type = smc.skills[uuid].type;
|
|
sv.box_tag= BoxSet.SKILL_TAG;
|
|
if(scale == 1){
|
|
sv.box_group=BoxSet.HERO
|
|
}else{
|
|
sv.box_group=BoxSet.MONSTER
|
|
}
|
|
this.add(sv);
|
|
}
|
|
}
|