"use strict"; cc._RF.push(module, '74654Gjc8xLApPRb+66p2Fx', 'cmp.holy.pray.wish'); // Scripts/mod/pray/cmp/cmp.holy.pray.wish.js "use strict"; var BridgeWindow = require("bridge.window"); var FxSVC = require("nx.fx.sv.expand"); var PrayMod = require("pray.mod"); var FXTogs = require("nx.fx.togs"); cc.Class({ "extends": BridgeWindow, properties: { svcList: { "default": null, type: FxSVC }, nodMenu: { "default": null, type: FXTogs }, nodChoice: { "default": [], type: cc.Node }, nodDesc: { "default": null, type: cc.Node } }, // 重载:参数打开 onOpenConfigs: function onOpenConfigs(_params) { var _this = this; var pray = PrayMod.getInstance(); this.group_id = _params.group_id; this.selectedPos = _params.select; this.preSelect = []; this.selectedPos.forEach(function (_nod) { _this.preSelect.push(_nod.lucky_holy_eqm); }); this.showLst = pray.getShow(); for (var i = 0; i < this.showLst.length; i++) { var lst = this.showLst[i]; var lsts = lst.lst; lsts.forEach(function (_item) { _item.inTeam = 0; _this.selectedPos.forEach(function (_pos) { if (_pos.lucky_holy_eqm == _item.group_id) { _item.inTeam = _pos.pos + 1; } }); }); } this.nodMenu.posTog = this.onTogType.bind(this); this.nodMenu.togTo(0); this.onTogType(0); //刷新已選列表 this.freshSelected(); this.onTouch(_params.focus || 0); // 引导辅助 if (nx.bridge.plot && nx.bridge.plot.isDoing()) { this.positionWish(); } // // 重建 // this.rebuild(); }, // 重载:关闭前 onPreClosed: function onPreClosed() { this.svcList.rebuild([]); }, freshSelected: function freshSelected() { var cfgs = game.configs.holy_eqm_lottery_data.data_wish_show; for (var i = 0; i < this.nodChoice.length; i++) { var nod = this.nodChoice[i]; var luckInfo = this.selectedPos[i]; var cmp = nx.gui.getComponent(nod, "", "cmp.holy.eqm.item"); if (cmp) { if (luckInfo) { if (luckInfo.lucky_holy_eqm == 0) { cmp.rebind(i, {}); } else { var info = cfgs[luckInfo.lucky_holy_eqm]; cmp.rebind(i, info); } } else { cmp.rebind(i, {}); } } } // this.freshWish(); }, onTogType: function onTogType(_idx) { var idx = parseInt(_idx) || 0; var change = idx + 23; if (this.curTag == change) { return; } this.curTag = change; this.freshEqm(); // this.freshWish(); }, freshEqm: function freshEqm() { var _this2 = this; this.showLst.forEach(function (item) { if (item.type == _this2.curTag) { _this2.svcList.rebuild(item.lst); } }); this.dealShow(2); }, onTouch: function onTouch(_idx) { for (var i = 0; i < this.nodChoice.length; i++) { var nod = this.nodChoice[i]; var cmp = nod.getComponent("cmp.holy.eqm.item"); if (cmp) { if (i != _idx) { cmp.outFocus(); } else { cmp.setFocus(); var data = cmp.mdata; if (cmp.mdata) { var desc = ""; if (nx.dt.objNEmpty(cmp.mdata)) { desc = nx.text.format("HolyWishDesc", data.name, data.desc); } nx.gui.setString(this.nodDesc, "txt", desc); } } } } this.select = _idx; // nx.gui.setActive( this.nodChoice[_idx], "base/focus", true ) ; }, onTouchChange: function onTouchChange(_idx) { // 點擊切換選中,并且 var snode = nx.gui.find(this.svcList.bindSCV, "view/content"); if (snode) { var nodes = snode.children; // 如果沒有選擇項 if (nx.dt.arrEmpty(this.selectedPos)) { for (var i = 0; i < nodes.length; i++) { var selectNode = nodes[i]; var cmp = selectNode.svItem; if (cmp) { if (i == _idx.index) { if (cmp.focus) { cmp.outFocus(); this.onFreshInfo({}); } else { cmp.setFocus(); this.onFreshInfo(cmp.mdata); } } else { cmp.outFocus(); } } } } else { for (var _i = 0; _i < nodes.length; _i++) { var _selectNode = nodes[_i]; var _cmp = _selectNode.svItem; if (_cmp) { if (_cmp.index == _idx.index) { if (_cmp.focus) { var pcmp = nx.gui.getComponent(this.nodChoice[_cmp.mdata.inTeam - 1], "", "cmp.holy.eqm.item"); if (pcmp) { pcmp.rebind(pcmp.index, {}); _cmp.mdata.inTeam = 0; nx.gui.setString(this.nodDesc, "txt", ""); } _cmp.rebind(_cmp.index, _cmp.mdata); } else { _cmp.mdata.inTeam = parseInt(this.select) + 1; _cmp.rebind(_cmp.index, _cmp.mdata); this.onFreshInfo(_cmp.mdata); } } else { // cmp.mdata.inTeam = 0; _cmp.rebind(_cmp.index, _cmp.mdata); } } } } // console.log( JSON.stringify( schemes ) + "当前的默认方案配置" + JSON.stringify( defaultSchemeInfo ) ); } }, onFreshInfo: function onFreshInfo(_info) { this.dealShow(1); var cmp = nx.gui.getComponent(this.nodChoice[this.select], "", "cmp.holy.eqm.item"); if (cmp) { cmp.rebind(this.select, _info); } var desc = nx.text.format("HolyWishDesc", _info.name, _info.desc); nx.gui.setString(this.nodDesc, "txt", desc); // nx.bridge.setIconS( nod, "", _info.icon ); // nx.gui.setActive( this.nodChoice[_idx], "base/focus", !nx.gui.find( this.nodChoice[_idx], "base/focus" ).active ) ; }, dealShow: function dealShow(_type) { var snode = nx.gui.find(this.svcList.bindSCV, "view/content"); // console.log( JSON.stringify( _item ) + "当前的默认方案配置" + snode ); if (snode) { var nodes = snode.children; var cmpd = nx.gui.getComponent(this.nodChoice[this.select], "", "cmp.holy.eqm.item"); for (var i = 0; i < nodes.length; i++) { var selectNode = nodes[i]; var cmp = selectNode.svItem; if (cmp && cmpd) { if (cmp.mdata.icon == cmpd.mdata.icon && _type == 1) { cmp.mdata.inTeam = 0; cmp.rebind(cmp.index, cmp.mdata); } if (cmp.mdata.inTeam == cmpd.mdata.inTeam && _type == 2 && cmp.mdata.icon != cmpd.mdata.icon) { cmp.mdata.inTeam = 0; cmp.rebind(cmp.index, cmp.mdata); } } } // console.log( JSON.stringify( schemes ) + "当前的默认方案配置" + JSON.stringify( defaultSchemeInfo ) ); } }, // 點擊確認 onTouchConfirm: function onTouchConfirm() { /*** * [25230]:{"group_id":1,"lucky_holy_eqm":[{"pos":0,"lucky_holy_eqm":101},{"pos":1,"lucky_holy_eqm":0},{"pos":2,"lucky_holy_eqm":0},{"pos":3,"lucky_holy_eqm":0}]} */ var holys = []; for (var i = 0; i < this.nodChoice.length; i++) { var nod = this.nodChoice[i]; var cmp = nod.getComponent("cmp.holy.eqm.item"); if (cmp) { if (!nx.dt.objEmpty(cmp.mdata)) { holys.push({ pos: i, lucky_holy_eqm: cmp.mdata.group_id }); } else { holys.push({ pos: i, lucky_holy_eqm: 0 }); } } } var pray = PrayMod.getInstance(); pray.sender25230(this.group_id, holys); }, freshWish: function freshWish() { var _this3 = this; var snode = nx.gui.find(this.svcList.bindSCV, "view/content"); // console.log( JSON.stringify( _item ) + "当前的默认方案配置" + snode ); if (snode) { var nodes = snode.children; var _loop = function _loop() { var selectNode = nodes[i]; var cmp = selectNode.svItem; if (cmp) { _this3.selectedPos.forEach(function (_nod) { if (_nod.lucky_holy_eqm == cmp.mdata.group_id) { cmp.setFocus(); } }); } }; for (var i = 0; i < nodes.length; i++) { _loop(); } // console.log( JSON.stringify( schemes ) + "当前的默认方案配置" + JSON.stringify( defaultSchemeInfo ) ); } }, /**** * 引导 ------- */ // 定位最弱的一个 positionWish: function positionWish() { var node = null; var chd = nx.gui.find(this.svcList.bindSCV, "view/content"); if (chd) { var nodes = chd.children; node = nodes[0]; // let node = null; // let children = this.svcList.bindSCV.content.children; // for( let i = 0; i < children.length; ++i ) { // let temp = children[ i ]; // if( temp.svItem && temp.svItem.mdata && temp.svItem.mdata.bid == 20401 ) { // node = temp; // break; // } // } if (!node) { nx.error("$ParterPage:定位特定英雄失败!"); node = chd[0]; if (!node) { return; } } var cell = nx.gui.find(this, "plot"); var pos = node.convertToWorldSpaceAR(cc.Vec2.ZERO); cell.position = cell.parent.convertToNodeSpaceAR(pos); cell.width = node.width; cell.height = node.height; cell.mdata = node.svItem.mdata; cell.index = node.svItem.index; nx.gui.setActive(this, "plot", true); } }, onTouchSelf: function onTouchSelf(_nod) { var nod = nx.gui.find(this, "plot"); if (nod) { this.onTouchChange(nod); } } }); cc._RF.pop();