68 lines
2.7 KiB
TypeScript
68 lines
2.7 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(pos: Vec3 = Vec3.ZERO,group:number,parent:Node,uuid:number=1001,
|
|
ap:number =10,t_pos:Vec3 = null,is_crit:boolean=false,crit_add:number=0)
|
|
{
|
|
var path = "game/skills/"+SkillSet[uuid].sp_name;
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
// console.log("load skill :",path,prefab)
|
|
var node = instantiate(prefab);
|
|
pos=v3(pos.x,pos.y)
|
|
node.parent = parent.parent;
|
|
node.setPosition(pos)
|
|
if(group==BoxSet.MONSTER) node.setScale(v3(-1*node.scale.x,node.scale.y));
|
|
var sv = node.getComponent(SkillCom);
|
|
// let angle=0
|
|
// if(SkillSet[uuid].angle){
|
|
// angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
|
|
// if(t_pos.x<0){
|
|
// angle+=180
|
|
// }
|
|
// }
|
|
// sv.angle = angle;
|
|
// console.log(group+" "+SkillSet[uuid].name+"angle:"+angle)
|
|
sv.s_uuid = uuid;
|
|
sv.s_name = SkillSet[uuid].name;
|
|
sv.ap = ap*SkillSet[uuid].ap;
|
|
sv.cd = SkillSet[uuid].cd;
|
|
sv.tg = SkillSet[uuid].tg;
|
|
sv.debtime = SkillSet[uuid].debtime;
|
|
sv.debuff = SkillSet[uuid].debuff;
|
|
sv.depb = SkillSet[uuid].depb;
|
|
sv.derate = SkillSet[uuid].derate;
|
|
sv.is_crit=is_crit
|
|
sv.crit_add=crit_add
|
|
// node.setScale(v3(node.scale.x*scale,node.scale.y))
|
|
sv.speed=SkillSet[uuid].speed;
|
|
sv.in_time=SkillSet[uuid].in;
|
|
|
|
sv.t_pos = t_pos; // 目标增量
|
|
sv.type = SkillSet[uuid].type;
|
|
sv.box_tag= BoxSet.SKILL_TAG;
|
|
sv.box_group=group
|
|
// console.log("load skill :",sv)
|
|
this.add(sv);
|
|
}
|
|
}
|