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,group:number,parent:Node, uuid:number=1001,atk:number =10,t_pos:Vec3 = null) { var path = "game/skills/"+smc.skills[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; //转换pos为世界坐标 node.setPosition(pos) var sv = node.getComponent(SkillCom)!; let scale =1 if(t_pos.x < pos.x){ scale= - 1 } let angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI; if(scale == -1){ angle = angle +180 } if(!smc.skills[uuid].angle){ angle=0 } sv.angle = angle; // console.log(smc.skills[uuid].name+"angle:"+angle) sv.s_uuid = uuid; sv.atk = atk; node.setScale(v3(node.scale.x*scale,node.scale.y)) sv.speed=smc.skills[uuid].speed; sv.dis=smc.skills[uuid].dis; sv.run_type=smc.skills[uuid].run; if(sv.dis == 0){ sv.run_type=2 } sv.in_time=smc.skills[uuid].in; sv.t_pos = t_pos; // 目标增量 sv.type = smc.skills[uuid].type; sv.box_tag= BoxSet.SKILL_TAG; sv.box_group=group // console.log("load skill :",sv) this.add(sv); } }