This commit is contained in:
pan@work
2024-09-05 10:54:28 +08:00
parent b80d2ff36e
commit d2a6ab3dce
17 changed files with 1792 additions and 2921 deletions

View 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();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b64b5d93-6a68-402a-a7ab-bf89db4a153b",
"files": [],
"subMetas": {},
"userData": {}
}

View 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();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "20c2c0dd-188e-41da-b74e-fdacae24b337",
"files": [],
"subMetas": {},
"userData": {}
}