"use strict";
|
cc._RF.push(module, '4237fFCt5xBi7XHwNZZUSbL', 'levupgrade_controller');
|
// Scripts/mod/levupgrade/levupgrade_controller.js
|
|
"use strict";
|
|
// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 这里填写详细说明,主要填写该模块的功能简要
|
// <br/>Create: 2019-04-26 11:26:17
|
// --------------------------------------------------------------------
|
var StoryEvent = require("story_event");
|
|
var LevupgradeController = cc.Class({
|
"extends": BaseController,
|
ctor: function ctor() {},
|
// 初始化配置数据
|
initConfig: function initConfig() {
|
var LevupgradeModel = require("levupgrade_model");
|
|
this.model = new LevupgradeModel();
|
this.model.initConfig();
|
this.wait_list = [];
|
},
|
// 返回当前的model
|
getModel: function getModel() {
|
return this.model;
|
},
|
// 注册监听事件
|
registerEvents: function registerEvents() {
|
var self = this;
|
|
if (self.can_play_drama_event == null) {
|
self.can_play_drama_event = gcore.GlobalEvent.bind(StoryEvent.BATTLE_RESULT_OVER, function () {
|
if (self.wait_list.length) {
|
self.wait_list.splice(0, 1);
|
}
|
|
if (Utils.next(self.wait_list) == null && self.cache_data) {
|
self.openMainWindow(true, self.cache_data);
|
self.cache_data = null;
|
} else {
|
gcore.GlobalEvent.fire(StoryEvent.PREPARE_PLAY_PLOT);
|
}
|
});
|
}
|
},
|
// 注册协议接受事件
|
registerProtocals: function registerProtocals() {
|
// this.RegisterProtocal(1110, this.on1110);
|
this.RegisterProtocal(10344, this.handle10344);
|
},
|
handle10344: function handle10344(data) {
|
this.openMainWindow(true, data);
|
},
|
// --desc:设置出现升级时候不能马上出面板
|
waitForOpenLevUpgrade: function waitForOpenLevUpgrade(status) {
|
if (this.wait_list && this.wait_list.length == 0) {
|
this.wait_list.push(true);
|
}
|
},
|
openMainWindow: function openMainWindow(status, data) {
|
var self = this;
|
|
if (!status) {
|
if (self.lev_window) {
|
self.lev_window.close();
|
self.lev_window = null;
|
}
|
} else {
|
if (Utils.next(self.wait_list) != null) {
|
self.cache_data = data;
|
return;
|
}
|
|
if (self.lev_window == null) {
|
var LevupgradeWindow = require("lev_upgrade_window");
|
|
self.lev_window = new LevupgradeWindow();
|
}
|
|
self.lev_window.open(data);
|
}
|
},
|
waitLevupgrade: function waitLevupgrade() {
|
// if (this.cache_data || this.lev_window || this.wait_list.length > 0) return true;
|
// if (this.lev_window) return true;
|
// return false;
|
return this.cache_data != null || this.lev_window != null || Utils.next(this.wait_list) != null;
|
},
|
logStatus: function logStatus() {
|
cc.log(this.cache_data);
|
cc.log(!!this.lev_window);
|
cc.log(this.wait_list);
|
}
|
});
|
module.exports = LevupgradeController;
|
|
cc._RF.pop();
|