卡牌技能位置

This commit is contained in:
2024-08-21 11:08:40 +08:00
parent a7f168dd72
commit 3f18763730
9 changed files with 81 additions and 15 deletions

View File

@@ -3,6 +3,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CSkillComp } from "./CSkillComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { SkillSet } from "../common/config/CardSet";
/** CSkill 模块 */
@ecs.register(`CSkill`)
export class CSkill extends ecs.Entity {
@@ -14,6 +16,7 @@ export class CSkill extends ecs.Entity {
/** 模块资源释放 */
destroy() {
this.remove(CSkillComp);
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
@@ -24,19 +27,30 @@ export class CSkill extends ecs.Entity {
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,camp:number = 1,uuid:number=1001) {
// var path = "game/monster/"+prefab_path;
console.log("load skill",this)
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)
let cskills = ecs.query(ecs.allOf(CSkillComp))
for (let index = 1; index <= 8; index++) {
if(smc.player_buffs[index].eid == 0){
pos.x=smc.player_buffs[index].x
pos.y=smc.player_buffs[index].y
smc.player_buffs[index].eid=this.eid
break
}
}
console.log("load skill",pos,smc.player_buffs)
node.setPosition(pos.x*-camp,pos.y,pos.z)
// 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');
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
});
this.skill_init(uuid,node,pos)
oops.message.dispatchEvent("cskill_load",this)