| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import LogicUnitManager from './LogicUnitManager'
- import DataModelManager from 'DataModelManager'
- import GameProcessManager from '../net/GameProcessManager'
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- ctor: function () {
- // behavior
- this._behaviorEventIDMap = {};
- this.lum = LogicUnitManager;
- this._behaviorEvent_index = 0;
-
- // data model
- this._dataEventIDMap = {};
- this.dmm = DataModelManager;
- this._dataEvent_index = 0;
-
- },
- onBehaviorEvent(behaviorName,eventName,callbackFun)
- {
- let behavior = this.lum.getBehavior(behaviorName);
- if(behavior)
- {
- let eventId = behavior.on(eventName,callbackFun,this);
- this._behaviorEventIDMap[this._behaviorEvent_index++] = {'behavior':behavior,'id':eventId};
- }
- },
- onDataModelChange(modelName,attributename,callbackFun)
- {
- let model = this.dmm.getModel(modelName);
- if(model && typeof model.on !== 'undefined')
- {
- let eventId = model.on(attributename,callbackFun,this);
- this._dataEventIDMap[this._dataEvent_index++] = {'m':model,'id':eventId};
- }
- },
- onLoad () {
- },
- start () {
- },
-
- onDestroy()
- {
- // behavior destroy
- for(let val in this._behaviorEventIDMap)
- {
- let eid = this._behaviorEventIDMap[val]['id'];
- let behavior = this._behaviorEventIDMap[val]['behavior'];
- if(behavior)
- {
- behavior.off(eid);
- }
- }
- // data model destroy
- for(let val in this._dataEventIDMap)
- {
- let m = this._dataEventIDMap[val]['m'],eid = this._dataEventIDMap[val]['id'];
- if(m)
- {
- m.off(eid);
- }
-
- }
- },
-
- });
|