"use strict"; cc._RF.push(module, '023a6O3lvpK5pDojYgNSZSj', 'seerpalace_controller'); // Scripts/mod/seerpalace/seerpalace_controller.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2019-03-21 10:11:26 // -------------------------------------------------------------------- var SeerpalaceEvent = require("seerpalace_event"); var SeerpalaceController = cc.Class({ "extends": BaseController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var SeerpalaceModel = require("seerpalace_model"); this.model = new SeerpalaceModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() { var self = this; if (self.init_role_event == null) { self.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () { gcore.GlobalEvent.unbind(self.init_role_event); self.init_role_event = null; //-- 上线时请求 // self.requestSeerpalaceChangeInfo() }); } }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(23213, this.handle23213.bind(this)); //--先知殿召唤返回 this.RegisterProtocal(23214, this.handle23214.bind(this)); //--先知殿置换当前状态数据 this.RegisterProtocal(23215, this.handle23215.bind(this)); //--先知殿置换结果 }, //打开先知界面 openSeerpalaceMainWindow: function openSeerpalaceMainWindow(bool, data) { if (bool) { var is_open = this.checkSeerpalaceIsOpen(); if (!is_open) { return; } var SeerpalaceWindow = require("seerpalace_main_window"); if (!this.seerpalace_window) { this.seerpalace_window = new SeerpalaceWindow(); } this.seerpalace_window.open(); } else { if (this.seerpalace_window) { this.seerpalace_window.close(); } this.seerpalace_window = null; } }, //先知商店 openShop: function openShop(bool, data) { if (bool) { var shopWindow = require("seerpalace_shop_window"); if (!this.shopWindow) { this.shopWindow = new shopWindow(); } this.shopWindow.open(); } else { if (this.shopWindow) { this.shopWindow.close(); } this.shopWindow = null; } }, handle23213: function handle23213(data) { if (data) { this.model.setLastSummonGroupId(data.group_id); var items = []; for (var i in data.rewards) { items[i] = {}; items[i].bid = data.rewards[i].base_id; items[i].num = data.rewards[i].num; } var MainUiConst = require("mainui_const"); require("mainui_controller").getInstance().openGetItemView(true, items, 0, { is_backpack: true }, MainUiConst.item_open_type.seerpalace); } }, handle23214: function handle23214(data) { this.model.setChangePartnerId(data.partner_id); //seerpalace_change_panel动态加载的,发射事件快,监听事件没注册 所以用不了 暂时拿model直接存 gcore.GlobalEvent.fire(SeerpalaceEvent.Change_Role_Info_Event, data); // this.model.setChangeInfo(data) }, handle23215: function handle23215(data) { message(data.msg); if (data.code == 1 && this.model.getChangeFlag()) { gcore.GlobalEvent.fire(SeerpalaceEvent.Change_Role_Success); this.model.setChangeFlag(false); } }, //-- 召唤预览 openSeerpalacePreviewWindow: function openSeerpalacePreviewWindow(status, index) { var self = this; if (status == true) { if (!self.seerpalace_preview) { var SeerpalacePreviewWindow = require("seerpalace_preview_window"); self.seerpalace_preview = new SeerpalacePreviewWindow(); } if (self.seerpalace_preview.isOpen() == false) { self.seerpalace_preview.open(index); } } else { if (self.seerpalace_preview) { self.seerpalace_preview.close(); self.seerpalace_preview = null; } } }, requestSeerpalaceSummon: function requestSeerpalaceSummon(group_id) { var protocal = {}; protocal.group_id = group_id; this.SendProtocal(23213, protocal); }, requestSeerpalaceChangeInfo: function requestSeerpalaceChangeInfo() { var protocal = {}; this.SendProtocal(23214, protocal); }, // -- 请求置换英雄 requestSeerpalaceChangeRole: function requestSeerpalaceChangeRole(partner_id, action) { var protocal = {}; protocal.partner_id = partner_id; protocal.action = action; if (action && action == 1) { this.model.setChangeFlag(true); } this.SendProtocal(23215, protocal); }, getSeerpalaceMainRoot: function getSeerpalaceMainRoot() { if (this.seerpalace_window) return this.seerpalace_window.root_wnd; }, // -- 获取先知殿是否开启 checkSeerpalaceIsOpen: function checkSeerpalaceIsOpen(not_tips) { var is_open = false; var RoleController = require("role_controller"); var role_vo = RoleController.getInstance().getRoleVo(); var limit_config = Config.recruit_high_data.data_seerpalace_const["common_limit"]; if (limit_config && role_vo.lev >= limit_config.val) { is_open = true; } else { is_open = false; if (!not_tips) { message(cc.js.formatStr(Utils.TI18N("%d级开启先知圣殿"), limit_config.val)); } } return is_open; } }); module.exports = SeerpalaceController; cc._RF.pop();