60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
|
|
/*
|
|
* @Author: dgflash
|
|
* @Date: 2021-11-18 17:47:56
|
|
* @LastEditors: dgflash
|
|
* @LastEditTime: 2022-08-04 15:43:04
|
|
*/
|
|
import { instantiate, Node, Prefab, Vec3 ,tween, v3,SpriteAtlas,Label,resources,SpriteFrame,Sprite} from "cc";
|
|
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { UIID } from "../common/config/GameUIConfig";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import{HeroCardViewComp} from "./HeroCardViewComp";
|
|
import { CardSet } from "../common/config/CardSet";
|
|
/** 角色实体 */
|
|
@ecs.register(`HeroCard`)
|
|
export class HeroCard extends ecs.Entity {
|
|
// 数据层
|
|
|
|
// 视图层
|
|
|
|
|
|
protected init() {
|
|
|
|
}
|
|
|
|
destroy(): void {
|
|
this.remove(HeroCardViewComp);
|
|
super.destroy();
|
|
}
|
|
|
|
/** 加载角色 */
|
|
load(pos: Vec3 = Vec3.ZERO,uuid:number=1001,parent:Node) {
|
|
// console.log("load hero",uuid);
|
|
// var path = "game/monster/"+prefab_path;
|
|
var path = "game/heros/hero_card";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.parent = parent;
|
|
// node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
|
node.setPosition(pos)
|
|
|
|
const url = 'game/heros/heros';
|
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = node.getChildByName("hero").getComponent(Sprite);
|
|
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].uuid);
|
|
});
|
|
|
|
var hcv = node.getComponent(HeroCardViewComp)!;
|
|
hcv.card_name=CardSet[uuid].name
|
|
hcv.card_uid=uuid
|
|
this.add(hcv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |