"use strict"; cc._RF.push(module, '87658evDxlKPqPceX0ZUrxL', 'cmp.wing.tips.unlocked'); // Scripts/mod/partner/wings/cmp/cmp.wing.tips.unlocked.js "use strict"; /****************************************************************** * * 解锁条件界面 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var RoleController = require("role_controller"); var ElfinController = require("elfin_controller"); var BackpackController = require("backpack_controller"); var BackPackConst = require("backpack_const"); cc.Class({ "extends": BridgeWindow, properties: { nodDesc: { "default": null, type: cc.Node }, nodProgress: { "default": null, type: cc.Node }, nodState: { "default": null, type: cc.Node }, nodMat: { "default": null, type: cc.Node }, nodOps: { "default": null, type: cc.Node } }, // 重载:参数打开 onOpenConfigs: function onOpenConfigs(_params) { // 当前的初始解锁达成状态 this.state = false; this.info = _params; // 道具刷新 this.freshItems(); // // 操作刷新 // this.freshOps(); }, // 道具刷新 freshItems: function freshItems() { var cfg = game.configs.sprite_data.data_hatch_data[this.info.id]; // 条件 // nx.gui.setString( this.nodDesc, "", cfg.desc2 ); // 具体条件参数 var hatch_cond = cfg.hatch_cond; // 角色的等级信息 var role = RoleController.getInstance().getRoleVo(); var wing = ElfinController.getInstance(); var model = wing.getModel(); var wingInfo = {}; // 堡垒信息 if (model) { wingInfo = model.getElfinTreeData(); } // 僚机信息 var BC = BackpackController.getInstance(); var BCModel = BC.getModel(); var allElfins = BCModel.getAllBackPackArray(BackPackConst.item_sub_type.ELFIN); this.progress = ""; var curnum = 0; if (hatch_cond[0]) { var cond = hatch_cond[0]; // 解锁条件的相关 描述 if (this.info.is_open != 1) { curnum = 0; if (cond == "lev") { var role_vo = RoleController.getInstance().getRoleVo(); if (role_vo) { curnum = role_vo.lev; if (role_vo.lev > hatch_cond[1]) { this.state = true; } } } else if (cond == "sprite_tree_break") { // 古樹X階解鎖 if (!nx.dt.objEmpty(wingInfo)) { curnum = wingInfo.break_lev; if (wingInfo.break_lev >= hatch_cond[1]) { this.state = true; } } } else if (cond == "sprite_tree_lv") { // 古樹X級解鎖 curnum = wingInfo.lev; if (wingInfo.lev >= hatch_cond[1]) { this.state = true; } } else if (cond == "has_any_sprite") { //[所有3星橙色精靈的bid]} var is_num = false; if (this.info.is_open == 2) { this.state = true; } // console.log( "所有的僚机数据" + JSON.stringify( allElfins ) ); for (var k in hatch_cond[1]) { var v = hatch_cond[1][k]; var num = BackpackController.getInstance().getModel().getBackPackItemNumByBid(v); // console.log( num + "拥有高级僚机的数量" + v ); if (num && num > 0) { is_num = true; this.state = true; curnum = num; break; } } } else if (cond == "sprite_tree_power") { //古樹戰力達到X解鎖 curnum = wingInfo.power; if (wingInfo.power >= hatch_cond[1]) { this.state = true; } } else if (cond == "sprite_power") { //精靈戰力達到X解鎖 if (!nx.dt.objEmpty(wingInfo)) { for (var _k in wingInfo.sprites) { var _v = wingInfo.sprites[_k]; var elfin_cfg = gdata("sprite_data", "data_elfin_data", _v.item_bid); //game.configs.sprite_data.data_elfin_data[v.item_bid] if (Object.keys(elfin_cfg).length == 1) { curnum = curnum + elfin_cfg.power; } else { curnum = curnum + 0; } } if (curnum >= hatch_cond[1] || this.info.is_open == 2) { this.state = true; } } else { curnum = 0; this.state = false; } } this.progress = curnum; } } // let ml = this.items.length > 5; // let lst = ml ? this.lstML : this.lstSL; // nx.gui.setActive( this.lstML, "", ml ); // nx.gui.setActive( this.lstSL, "", !ml ); // lst.rebuild( this.items ); this.freshState(); }, // 刷新条件是否达成 以及材料刷新 freshState: function freshState() { // console.log( "当前的完成状态" + this.state ); var clr = this.state ? new cc.Color().fromHEX("#068b06") : new cc.Color().fromHEX("#ff0000"); nx.gui.setColor(this.nodState, "", clr); nx.gui.setColor(this.nodProgress, "txt", clr); nx.gui.setString(this.nodState, "", this.state ? nx.text.getKey("btn_guild_action_item_btn_type") : nx.text.getKey("lab_recruit_hero_window_tip_3")); var cbc = game.configs.sprite_data.data_hatch_data[this.info.id]; // 条件 nx.gui.setString(this.nodDesc, "", cbc.desc2); nx.gui.setString(this.nodProgress, "txt", this.progress); nx.gui.setString(this.nodProgress, "max", "/" + (nx.dt.arrGood(cbc.hatch_cond[1]) ? 1 : cbc.hatch_cond[1])); // 消耗 this.needs = []; if (nx.dt.arrEmpty(cbc.expend)) { // 无消耗 nx.gui.hideAllChildren(this.nodMat); } else { // console.log( "配置数据" + JSON.stringify( cbc ) ); var model = BackpackController.getInstance().getModel(); var chds = this.nodMat.children; for (var i = 0; i < chds.length; ++i) { var node = chds[i]; var info = cbc.expend[i]; if (!info) { node.active = false; continue; } node.active = true; var cfg = Utils.getItemConfig(info[0]); nx.bridge.setIconS(node, "icon", cfg.icon); var have = model.getItemNumByBid(info[0]); var str = cc.js.formatStr("%s/%s", Utils.getMoneyString(have), Utils.getMoneyString(info[1])); nx.gui.setString(node, "txt", info[1]); var _clr = have >= info[1] ? cc.Color.WHITE : cc.Color.RED; nx.gui.setColor(node, "txt", _clr); // 缺少记录 if (have < info[1]) { this.needs.push(info[0]); } } } }, onTouchConfirm: function onTouchConfirm() { if (!this.info) { return; } if (this.info.is_open == 0) { nx.tbox(nx.text.getKey("elfin_hatch_unlock_4")); return; } var hatch_cfg = game.configs.sprite_data.data_hatch_data[this.info.id]; if (hatch_cfg) { for (var i in hatch_cfg.expend) { var v = hatch_cfg.expend[i]; var item_bid = v[0]; var item_num = v[1]; var count = BackpackController.getInstance().getModel().getItemNumByBid(item_bid); if (count < item_num) { nx.tbox(nx.text.getKey("elfin_hatch_unlock_5")); return; } } } var EC = ElfinController.getInstance(); if (EC) { EC.sender26535(this.info.id); } } }); cc._RF.pop();