156 lines
4.2 KiB
JavaScript
156 lines
4.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '9c11c0ZxoNO67nbG9n6ID1I', 'cmp.summon.crystal');
|
||
|
|
// Scripts/mod/summon/crystal/cmp.summon.crystal.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
||
|
|
*
|
||
|
|
* 水晶召唤页
|
||
|
|
*
|
||
|
|
* 2018.05.18
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var MenuPage = require("cmp.com.menu.page");
|
||
|
|
var CRYModel = require("summon.crystal.mod");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var BackPackController = require("backpack_controller");
|
||
|
|
var BridgeItemBinder = require("bridge.binder.item.icon.count");
|
||
|
|
cc.Class({
|
||
|
|
"extends": MenuPage,
|
||
|
|
properties: {
|
||
|
|
nodCoin: {
|
||
|
|
"default": null,
|
||
|
|
type: BridgeItemBinder
|
||
|
|
},
|
||
|
|
nodCard: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodSummon: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
lstChoices: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
defGroup: {
|
||
|
|
"default": 1000
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 载入
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this._super();
|
||
|
|
this.lstChoices.children.forEach(function (_node) {
|
||
|
|
nx.gui.setActive(_node, "circle/off", false);
|
||
|
|
nx.gui.setActive(_node, "circle/on", false);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function onDestroy() {
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
// 显示
|
||
|
|
onEnable: function onEnable() {
|
||
|
|
this.group = 0;
|
||
|
|
this.price = {};
|
||
|
|
// 首次设置
|
||
|
|
if (!nx.dt.numPositive(this.group, false)) {
|
||
|
|
this.onTouchGroup(-1);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 更新数据
|
||
|
|
updateData: function updateData(_data) {
|
||
|
|
// 置空
|
||
|
|
if (nx.dt.objEmpty(_data)) {
|
||
|
|
this.setEmpty();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 点击货币
|
||
|
|
onTouchCoin: function onTouchCoin() {
|
||
|
|
nx.bridge.createPanel("WndSummonCrystalShop");
|
||
|
|
},
|
||
|
|
// 点击说明
|
||
|
|
onTouchRule: function onTouchRule() {
|
||
|
|
// 召唤配置
|
||
|
|
var DATA = game.configs.recruit_high_data;
|
||
|
|
var rule = DATA.data_seerpalace_const.game_rule1;
|
||
|
|
if (nx.dt.objNEmpty(rule) && nx.dt.strNEmpty(rule.desc)) {
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
TC.showTextPanel("tip", rule.desc);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 选中阵营
|
||
|
|
onTouchGroup: function onTouchGroup(_group_id) {
|
||
|
|
var gid = parseInt(_group_id) || 0;
|
||
|
|
if (gid < 0) {
|
||
|
|
this.lstChoices.children.forEach(function (_node) {
|
||
|
|
nx.gui.setActive(_node, "circle/off", false);
|
||
|
|
nx.gui.setActive(_node, "circle/on", false);
|
||
|
|
});
|
||
|
|
var _DATA = game.configs.recruit_high_data;
|
||
|
|
var _gdata = _DATA.data_seerpalace_data[1000];
|
||
|
|
nx.bridge.setIconS(this.nodSummon, "price/icon", _gdata.item_once[0][0]);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (this.group == gid) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.lstChoices.children.forEach(function (_node) {
|
||
|
|
var focus = _node.name == 'c' + gid;
|
||
|
|
nx.gui.setActive(_node, "circle/off", false);
|
||
|
|
nx.gui.setActive(_node, "circle/on", focus);
|
||
|
|
});
|
||
|
|
var DATA = game.configs.recruit_high_data;
|
||
|
|
var gdata = DATA.data_seerpalace_data[gid];
|
||
|
|
nx.bridge.setIconS(this.nodSummon, "price/icon", gdata.item_once[0][0]);
|
||
|
|
this.group = gid;
|
||
|
|
this.price = gdata.item_once[0];
|
||
|
|
},
|
||
|
|
// 概率查看
|
||
|
|
onTouchGroupRate: function onTouchGroupRate(_group_id) {
|
||
|
|
var DATA = game.configs.recruit_high_data;
|
||
|
|
var cfgs = DATA.data_seerpalace_award[_group_id];
|
||
|
|
if (cfgs) {
|
||
|
|
nx.bridge.createPanel("WndSummonCrystalRates", cfgs);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 点击召唤
|
||
|
|
onTouchSummon: function onTouchSummon() {
|
||
|
|
if (!nx.dt.numPositive(this.group) || nx.dt.arrEmpty(this.price)) {
|
||
|
|
nx.tbox("SummonCampTip");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var BC = BackPackController.getInstance();
|
||
|
|
var count = BC.getModel().getBackPackItemNumByBid(this.price[0]);
|
||
|
|
if (count < this.price[1]) {
|
||
|
|
nx.tbox("SummonItemNotEnough");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
CRYModel.getInstance().reqSummon(this.group, function (_ok, _data) {
|
||
|
|
// 失败
|
||
|
|
if (!_ok) {
|
||
|
|
nx.tbox(_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var list = [];
|
||
|
|
var rewards = _data.rewards || [];
|
||
|
|
rewards.forEach(function (_re) {
|
||
|
|
list.push({
|
||
|
|
bid: _re.base_id,
|
||
|
|
num: _re.num
|
||
|
|
});
|
||
|
|
});
|
||
|
|
if (nx.dt.arrNEmpty(list)) {
|
||
|
|
nx.bridge.createPanel("PopupRewards", {
|
||
|
|
list: list
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|