"use strict"; cc._RF.push(module, 'cce577r/KFKnZll5ghWatN0', 'halidom_controller'); // Scripts/mod/home/base_kernel/halidom_controller.js "use strict"; var BridgeController = require("bridge.controller"); var RoleController = require("role_controller"); var RoleEvent = require("role_event"); var BackPackConst = require("backpack_const"); var BackpackEvent = require("backpack_event"); var HalidomEvent = require("halidom_event"); cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var HalidomModel = require("halidom_model"); this.model = new HalidomModel(this); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() {}, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(22200, this.handle22200.bind(this)); //圣物数据 this.RegisterProtocal(22201, this.handle22201.bind(this)); //圣物数据更新 this.RegisterProtocal(22202, this.handle22202.bind(this)); //激活圣物 this.RegisterProtocal(22203, this.handle22203.bind(this)); //注能圣物 this.RegisterProtocal(22204, this.handle22204.bind(this)); //进阶圣物 this.RegisterProtocal(22205, this.handle22205.bind(this)); // 圣物升级 }, reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["halidom_data" // 基础核心 ]; this.loadConfigs(cfgs, function (_ret, _data) { // nx.dt.fnInvoke( _cb, true ); _this.sender22200(_cb); }); }, // 请求圣物数据 sender22200: function sender22200(_cb) { var protocal = {}; this.SendProtocal(22200, protocal, _cb); }, handle22200: function handle22200(data) { if (data) { this.model.setAllHalidomData(data.list); gcore.GlobalEvent.fire(HalidomEvent.Get_Halidom_Data_Event); } }, // 圣物数据更新 handle22201: function handle22201(data) { if (data) { var is_have = this.model.updateHalidomData(data); gcore.GlobalEvent.fire(HalidomEvent.Update_Halidom_Data_Event, data.id); if (!is_have) { // 新增的,则为解锁 this.openHalidomUnlockWindow(true, data); } } }, // 请求激活圣物 sender22202: function sender22202(id, list) { var protocal = {}; protocal.id = id; protocal.list = list; this.SendProtocal(22202, protocal); }, handle22202: function handle22202(data) { if (data) { if (data.msg != "") { nx.tbox(data.msg); } } }, // 请求升级圣物 sender22203: function sender22203(id) { var protocal = {}; protocal.id = id; this.SendProtocal(22203, protocal); }, handle22203: function handle22203(data) { if (data) { // message(data.msg) } }, // 请求进阶圣物 sender22204: function sender22204(id, list1, list2) { var protocal = {}; protocal.id = id; this.cur_halidom_id = id; protocal.list1 = list1; protocal.list2 = list2; this.SendProtocal(22204, protocal); }, handle22204: function handle22204(data) { if (data) { // message(data.msg) if (data.code == 1) { // this.openHalidomUpStepWindow(true, data.id) } } }, // 圣物升级 升级反馈 暂时不显示 handle22205: function handle22205(data) { if (data && data.id) { // this.openHalidomUpLvWindow( true, data.id ) } }, openKernelUpLvWnd: function openKernelUpLvWnd(status, _lev, _camp) { if (status == true) { nx.bridge.createPanel("WndKernelUplevel", { level: _lev, camp: _camp }); } else { nx.bridge.closePanel("WndKernelUplevel"); } }, // 基础核心 进阶面板 openHalidomUpgrade: function openHalidomUpgrade(status, _item_bid, _sid, _pos, _from, _camp, _cb) { if (status == true) { nx.bridge.createPanel("WndKernelUpgrade", { item_bid: _item_bid, skill_id: _sid, pos: _pos, from: _from, camp: _camp || 0, cb: _cb }); } else { nx.bridge.closePanel("WndKernelUpgrade"); } }, // 道具数量变化计算红点 checkNeedUpdateRedStatus: function checkNeedUpdateRedStatus(item_list) { if (item_list == null || Utils.next(item_list) == null) return; var cost_cfg = game.configs.halidom_data.data_const["halidom_cost"]; if (cost_cfg) { var is_have = false; for (var k in item_list) { var v = item_list[k]; if (v.config) { for (var a in cost_cfg.val || {}) { var id = cost_cfg.val[a] || null; if (id == v.config.id) { is_have = true; break; } } } if (is_have) { break; } } if (is_have) { // this.model.calculateHalidomRedStatus() } } }, openKernelUnlocked: function openKernelUnlocked(status, _camp) { if (status == true) { nx.bridge.createPanel("WndKernelUnlocked", _camp); } else { nx.bridge.closePanel("WndKernelUnlocked"); } }, // @ 打开家园 基础核心模块 openHomeKernelWind: function openHomeKernelWind(status) { if (status == true) { nx.bridge.createPanel("WndKernelMain"); } else { nx.bridge.closePanel("WndKernelMain"); } }, // @ 打开进阶成功界面 openHalidomUpStepWindow: function openHalidomUpStepWindow(status, id) { if (status == true) { if (this.up_step_window == null) { var HalidomUpStepWindow = require("skill_unlock_window"); this.up_step_window = new HalidomUpStepWindow(id, true, this.cur_halidom_id); } this.up_step_window.open(); } else { if (this.up_step_window) { this.up_step_window.close(); } } }, // @ 打开圣物升级界面 openHalidomUpLvWindow: function openHalidomUpLvWindow(status, id) { if (status == true) { if (this.up_lv_window == null) { var HalidomUpLvWindow = require("halidom_lv_up_window"); this.up_lv_window = new HalidomUpLvWindow(); } this.up_lv_window.open(id); } else { if (this.up_lv_window) { this.up_lv_window.close(); this.up_lv_window = null; } } }, /************ * [22201]:{"id":2,"lev":1,"exp":0,"step":0,"all_attr":[{"name":104,"val":921},{"name":101,"val":77}]} */ // @ 打开圣物激活界面 openHalidomUnlockWindow: function openHalidomUnlockWindow(status, _data) { if (status == true) { nx.bridge.createPanel("WndKernelUnlockedBack", _data); } else { nx.bridge.closePanel("WndKernelUnlockedBack"); } }, // 打开圣物进阶预览 openHalidomStepPreView: function openHalidomStepPreView(status, id) { if (status == true) { if (this.step_pre_view == null) { var HalidomStepPreView = require("halidom_step_preview"); this.step_pre_view = new HalidomStepPreView(); } this.step_pre_view.open(id); } else { if (this.step_pre_view) { this.step_pre_view.close(); this.step_pre_view = null; } } } }); cc._RF.pop();