卡牌技能
This commit is contained in:
61
assets/script/game/monster/CSkill.ts
Normal file
61
assets/script/game/monster/CSkill.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Prefab,instantiate,Vec3,v3 ,SpriteAtlas,resources,Sprite,Node} from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CSkillComp } from "./CSkillComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
/** CSkill 模块 */
|
||||
@ecs.register(`CSkill`)
|
||||
export class CSkill extends ecs.Entity {
|
||||
CSkillView!: CSkillComp;
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
start(){
|
||||
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
|
||||
var path = "game/heros/skill";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.getChildByName("skill").setScale(node.getChildByName("skill").scale.x*camp, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/skill';
|
||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = node.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame('1002');
|
||||
});
|
||||
this.skill_init(uuid,node,pos)
|
||||
oops.message.dispatchEvent("cskill_load",this)
|
||||
|
||||
}
|
||||
|
||||
skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(CSkillComp)
|
||||
mv.camp = 1;
|
||||
this.add(mv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** CSkill 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsCSkillSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user