Files
heros/assets/script/game/skills/Skill.ts
2024-08-21 17:55:15 +08:00

64 lines
2.0 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 { 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,skill_name:string = "base",atk:number =10,angle = 0,t_pos:Vec3 = null) {
var path = "game/skills/"+skill_name;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.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;
if(scale == 1){
sv.change_collider_group(BoxSet.HERO_SKILL)
}else{
sv.change_collider_group(BoxSet.MONSTER_SKILL)
}
this.add(sv);
}
}
/** Skill 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
export class EcsSkillSystem extends ecs.System {
constructor() {
super();
// this.add(new ecs.ComblockSystem());
}
}