165 lines
4.5 KiB
JavaScript
165 lines
4.5 KiB
JavaScript
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* 水晶召唤页
|
|
*
|
|
* 2018.05.18
|
|
******************************************************************/
|
|
|
|
const MenuPage = require( "cmp.com.menu.page" );
|
|
const CRYModel = require( "summon.crystal.mod" );
|
|
const TipsController = require( "tips_controller" );
|
|
const BackPackController = require( "backpack_controller" );
|
|
const 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() {
|
|
|
|
this._super();
|
|
|
|
this.lstChoices.children.forEach( _node => {
|
|
nx.gui.setActive( _node, "circle/off", false );
|
|
nx.gui.setActive( _node, "circle/on", false );
|
|
} );
|
|
|
|
},
|
|
|
|
// 销毁
|
|
onDestroy: function() {
|
|
|
|
this._super();
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
this.group = 0;
|
|
this.price = {};
|
|
// 首次设置
|
|
if( !nx.dt.numPositive( this.group, false ) ) {
|
|
this.onTouchGroup( -1 );
|
|
}
|
|
},
|
|
|
|
// 更新数据
|
|
updateData: function( _data ) {
|
|
|
|
// 置空
|
|
if( nx.dt.objEmpty( _data ) ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
},
|
|
|
|
// 点击货币
|
|
onTouchCoin: function() {
|
|
nx.bridge.createPanel( "WndSummonCrystalShop" );
|
|
},
|
|
|
|
// 点击说明
|
|
onTouchRule: function() {
|
|
|
|
// 召唤配置
|
|
const DATA = game.configs.recruit_high_data;
|
|
const rule = DATA.data_seerpalace_const.game_rule1;
|
|
if( nx.dt.objNEmpty( rule ) && nx.dt.strNEmpty( rule.desc ) ) {
|
|
const TC = TipsController.getInstance();
|
|
TC.showTextPanel( "tip", rule.desc );
|
|
}
|
|
},
|
|
|
|
// 选中阵营
|
|
onTouchGroup: function( _group_id ) {
|
|
|
|
let gid = parseInt( _group_id ) || 0;
|
|
if( gid < 0 ){
|
|
this.lstChoices.children.forEach( _node => {
|
|
nx.gui.setActive( _node, "circle/off", false );
|
|
nx.gui.setActive( _node, "circle/on", false );
|
|
} );
|
|
const DATA = game.configs.recruit_high_data;
|
|
let 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( _node => {
|
|
let focus = ( _node.name == 'c' + gid );
|
|
nx.gui.setActive( _node, "circle/off", false );
|
|
nx.gui.setActive( _node, "circle/on", focus );
|
|
} );
|
|
|
|
const DATA = game.configs.recruit_high_data;
|
|
let 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( _group_id ) {
|
|
|
|
const DATA = game.configs.recruit_high_data;
|
|
let cfgs = DATA.data_seerpalace_award[ _group_id ];
|
|
if( cfgs ) {
|
|
nx.bridge.createPanel( "WndSummonCrystalRates", cfgs );
|
|
}
|
|
},
|
|
|
|
// 点击召唤
|
|
onTouchSummon: function() {
|
|
|
|
if( !nx.dt.numPositive( this.group ) ||
|
|
nx.dt.arrEmpty( this.price ) ) {
|
|
nx.tbox( "SummonCampTip" );
|
|
return;
|
|
}
|
|
|
|
const BC = BackPackController.getInstance();
|
|
let count = BC.getModel().getBackPackItemNumByBid( this.price[0] );
|
|
if( count < this.price[1] ) {
|
|
nx.tbox( "SummonItemNotEnough" );
|
|
return;
|
|
}
|
|
|
|
CRYModel.getInstance().reqSummon( this.group, ( _ok, _data ) => {
|
|
|
|
// 失败
|
|
if( !_ok ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
|
|
let list = [];
|
|
let rewards = _data.rewards || [];
|
|
rewards.forEach( _re => {
|
|
list.push( { bid: _re.base_id, num: _re.num } );
|
|
});
|
|
if( nx.dt.arrNEmpty( list ) ) {
|
|
nx.bridge.createPanel( "PopupRewards", {
|
|
list: list
|
|
} );
|
|
}
|
|
} );
|
|
|
|
},
|
|
|
|
} );
|