dd
This commit is contained in:
50
assets/script/game/gui/InfoBox.ts
Normal file
50
assets/script/game/gui/InfoBox.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { instantiate, Prefab, Vec3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { InfoBoxCom } from "./InfoBoxCom";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
|
||||
/** InfoBox 模块 */
|
||||
@ecs.register(`InfoBox`)
|
||||
export class InfoBox extends ecs.Entity {
|
||||
/** ---------- 数据层 ---------- */
|
||||
// InfoBoxModel!: InfoBoxModelComp;
|
||||
|
||||
/** ---------- 业务层 ---------- */
|
||||
// InfoBoxBll!: InfoBoxBllComp;
|
||||
|
||||
/** ---------- 视图层 ---------- */
|
||||
InfoBoxView!: InfoBoxCom
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,uuid:number=101,prefab_path:string) {
|
||||
var path = "game/gui/"+prefab_path;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.SkillLayer!.node!;
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
// const url = 'game/heros/player';
|
||||
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
// const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
|
||||
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
|
||||
// });
|
||||
// var rv = node.getComponent(MonsterViewComp)!;
|
||||
// this.add(rv);
|
||||
var mv = node.getComponent(InfoBoxCom)!;
|
||||
this.add(mv);
|
||||
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
this.remove(InfoBoxCom);
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/script/game/gui/InfoBox.ts.meta
Normal file
9
assets/script/game/gui/InfoBox.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b64b5d93-6a68-402a-a7ab-bf89db4a153b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
43
assets/script/game/gui/InfoBoxCom.ts
Normal file
43
assets/script/game/gui/InfoBoxCom.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { _decorator ,Node} from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('InfoBoxCom')
|
||||
@ecs.register('InfoBox', false)
|
||||
export class InfoBoxCom extends CCComp {
|
||||
@property(Node)
|
||||
n_name:Node =null!
|
||||
@property(Node)
|
||||
n_hp:Node =null!
|
||||
@property(Node)
|
||||
n_atk:Node =null!
|
||||
@property(Node)
|
||||
n_info:Node =null!
|
||||
@property(Node)
|
||||
n_atk_cd:Node =null!
|
||||
@property(Node)
|
||||
n_skillcd:Node =null!
|
||||
|
||||
n_type:number=0; // 0:技能 1 精灵
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
console.log("InfoBoxCom start");
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/gui/InfoBoxCom.ts.meta
Normal file
9
assets/script/game/gui/InfoBoxCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "20c2c0dd-188e-41da-b74e-fdacae24b337",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user