"use strict"; cc._RF.push(module, 'd64eb5a64xIB7WVmvqpWcNq', 'cmp.summon.rule.wnd'); // Scripts/mod/summon/com/cmp.summon.rule.wnd.js "use strict"; /****************************************************************** * * 召唤规则说明 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var FxSVC = require("nx.fx.sv.expand"); var HEADER_ID = 1; var LIST_IDS = [2, 5]; cc.Class({ "extends": BridgeWindow, properties: { nodHead: { "default": null, type: cc.Node }, nodList: { "default": null, type: cc.Node }, nodRates: { "default": null, type: cc.Node }, svcList: { "default": null, type: FxSVC } }, // 重载:参数打开 onOpenConfigs: function onOpenConfigs(_params) { if (_params === void 0) { _params = {}; } var key = _params.key || 'recruit_data'; this.cfgs = game.configs[key]; if (nx.dt.objEmpty(this.cfgs)) { return; } // 重建列表 this.rebuild(); this.nodRates.active = false; }, // 重建列表 rebuild: function rebuild() { // 表头 var data = this.cfgs ? this.cfgs.data_explain : null; if (nx.dt.objEmpty(data)) { return; } var head = data ? data[HEADER_ID] : null; this.nodHead.active = nx.dt.objNEmpty(head); if (this.nodHead.active) { nx.gui.setString(this.nodHead, "title/txt", nx.text.getKey(head.title)); nx.gui.setString(this.nodHead, "txt", nx.text.getKey(head.desc)); } // 召唤明细 var build = function build(_node, _data) { _node.active = nx.dt.objNEmpty(_data); if (!_node.active) { return; } nx.gui.setString(_node, "title/txt", nx.text.getKey(_data.title)); var btn = nx.gui.find(_node, "title/detail"); btn.sumInfos = _data; var arr = _data.desc.split("$"); var cnt = Math.floor(arr.length / 2); var root = nx.gui.find(_node, "rates"); nx.gui.gocChildren(root, "", cnt, root.children[0]); for (var i = 0; i < cnt; ++i) { var idx = i * 2; var item = root.children[i]; nx.gui.setString(item, "name", nx.text.getKey(arr[idx])); nx.gui.setString(item, "rate", arr[idx + 1]); } }; // 循环创建 var chds = this.nodList.children; var count = LIST_IDS[1] - LIST_IDS[0] + 1; nx.gui.gocChildren(this.nodList, "", count, chds[0]); for (var i = 0; i < count; ++i) { build(chds[i], data ? data[i + LIST_IDS[0]] : null); } ; }, // 具体掉落率 onTouchRate: function onTouchRate(_btn) { if (!_btn || nx.dt.objEmpty(_btn.sumInfos)) { return; } var gid = 100; switch (_btn.sumInfos.id) { case 2: gid = 100; break; case 3: gid = 200; break; case 4: gid = 300; break; case 5: gid = 400; break; default: break; } var data = this.cfgs ? this.cfgs.data_summon_data : null; var list = data ? data[gid] : null; if (nx.dt.objEmpty(data)) { return; } var arr = []; for (var i in list) { var t = list[i]; var rate = parseFloat(t.summon_desc) || 0; rate = Math.floor(rate * 1000) / 1000; if (rate > 0) { arr.push({ id: t.id, base_id: t.base_id, rate: rate }); } } // 按几率排序 arr.sort(function (_a, _b) { return _b.rate - _a.rate; }); this.svcList.rebuild(arr); this.nodRates.active = true; }, // 掉落界面关闭 onCloseRates: function onCloseRates() { this.nodRates.active = false; } }); cc._RF.pop();