dd
This commit is contained in:
@@ -17,7 +17,9 @@ export class data extends ecs.Entity {
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>(dataViewComp,dataModelComp);
|
||||
}
|
||||
|
||||
changeHp(min: number, max: number){
|
||||
var data = this.dataModel;
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
|
||||
@@ -1,18 +1,36 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
|
||||
import { CCVMParentComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCVMParentComp";
|
||||
|
||||
|
||||
/** 数据层对象 */
|
||||
@ecs.register('dataModel')
|
||||
export class dataModelComp extends ecs.Comp {
|
||||
export class dataModelComp extends CCVMParentComp {
|
||||
/** 提供 MVVM 组件使用的数据 */
|
||||
private vm: dataVM = new dataVM();
|
||||
/** VM 组件绑定数据 */
|
||||
vm: any = {
|
||||
name : "数据测试",
|
||||
/** 当前等级 */
|
||||
porwer: 0,
|
||||
/** 当前经验 */
|
||||
def : 0,
|
||||
/** 下级经验 */
|
||||
speed : 0,
|
||||
hp: {
|
||||
min:50,
|
||||
max:100
|
||||
}
|
||||
};
|
||||
|
||||
/** 显示数据添加到 MVVM 框架中监视 */
|
||||
vmAdd() {
|
||||
console.log("dataModelComp vmAdd");
|
||||
VM.add(this.vm, "data");
|
||||
}
|
||||
|
||||
changeHp(min: number, max: number) {
|
||||
this.vm.hp.min =this.vm.hp.min +min
|
||||
this.vm.hp.max =this.vm.hp.max +max
|
||||
}
|
||||
/** 显示数据从 MVVM 框架中移除 */
|
||||
vmRemove() {
|
||||
VM.remove("data");
|
||||
@@ -26,21 +44,3 @@ export class dataModelComp extends ecs.Comp {
|
||||
}
|
||||
}
|
||||
|
||||
class dataVM {
|
||||
/** 英雄名称 */
|
||||
name: string = "数据测试";
|
||||
/** 当前等级 */
|
||||
porwer: number = 0;
|
||||
/** 当前经验 */
|
||||
def: number = 0;
|
||||
/** 下级经验 */
|
||||
speed: number = 0;
|
||||
|
||||
reset() {
|
||||
this.name = "";
|
||||
this.porwer = 0;
|
||||
this.def = 0;
|
||||
this.speed = 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user