"use strict";
|
cc._RF.push(module, '09beffHJFVKu66tOjY0aWs1', 'red_mgr');
|
// Scripts/common/red_mgr.js
|
|
"use strict";
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
window.RedIds = {
|
PartnerSummon: 1,
|
Endless: 2,
|
StoneDungeon: 3,
|
Primus: 4,
|
Heroexpedit: 5,
|
StarTower: 6,
|
Hallow: 7,
|
NewfirstchargeModel: 8,
|
HeroAll: 21,
|
RefuseHero: 22,
|
GuildDonate: 10,
|
//公会捐献
|
GuildActive: 11,
|
//公会活跃
|
GuildBoss: 12,
|
//公会副本
|
GuildSkill: 13,
|
//公会技能
|
Ladder: 101 //跨服天梯
|
|
};
|
window.RedMgr = cc.Class({
|
ctor: function ctor() {
|
this.handler_queue = []; // this.mainloop_timer = gcore.Timer.set(this.mainloop.bind(this), 1000, -1);
|
},
|
addCalHandler: function addCalHandler(handler, id) {
|
if (!handler) return;
|
|
if (id) {
|
var handler_data = {};
|
handler_data.handler = handler;
|
handler_data.id = id;
|
var had_in_queue = false;
|
|
for (var handler_i in this.handler_queue) {
|
if (_typeof(this.handler_queue[handler_i]) == "object") {
|
if (this.handler_queue[handler_i].id === id) {
|
had_in_queue = true;
|
break;
|
}
|
}
|
}
|
|
if (had_in_queue) {
|
return;
|
} else {
|
handler = handler_data;
|
}
|
}
|
|
this.handler_queue.push(handler);
|
if (!this.mainloop_timer) this.mainloop_timer = gcore.Timer.set(this.mainloop.bind(this), 1000, -1);
|
},
|
mainloop: function mainloop() {
|
var cur_handler = this.handler_queue.shift();
|
|
if (cur_handler) {
|
if (typeof cur_handler == "function") {
|
cur_handler();
|
} else {
|
if (cur_handler = cur_handler.handler) cur_handler();
|
}
|
}
|
|
if (this.handler_queue.length == 0) {
|
if (this.mainloop_timer) {
|
gcore.Timer.del(this.mainloop_timer);
|
this.mainloop_timer = null;
|
}
|
}
|
}
|
});
|
|
RedMgr.getInstance = function () {
|
if (!RedMgr.instance) {
|
RedMgr.instance = new RedMgr();
|
}
|
|
return RedMgr.instance;
|
};
|
|
module.exports = RedMgr;
|
|
cc._RF.pop();
|