/****************************************************************** * * 水晶卡牌召喚 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const CRYModel = require( "summon.crystal.mod" ); cc.Class( { extends: BridgeWindow, properties: { lstChoices: { default: null, type: cc.Node }, nodSummon: { default: null, type: cc.Node }, defGroup: { default: 10000 }, }, // 重载:参数打开 onOpenConfigs: function( _params ) { this.lstChoices.children.forEach( _node => { nx.gui.setActive( _node, "focus", false ); } ); this.rebuild(); }, // 重建列表 rebuild: function( ) { // 召唤配置 const IDS = [ 10000, 20000, 30000, 40000, 50000 ]; const DATA = game.configs.recruit_high_data.data_seerpalace_data; for( let i = 0; i < IDS.length; ++i ) { let id = "" + IDS[i]; let price = DATA[id].item_once[0]; let node = nx.gui.find( this.lstChoices, "c" + id ); nx.gui.setString( node, "price/txt", price[1] ); nx.bridge.setIconS( node, "price/icon", price[0] ); } // 默认 this.onTouchGroup( this.defGroup ); }, // 选择阵营 onTouchGroup: function( _groupId ) { let gid = parseInt( _groupId ) || 0; if( this.group == gid ) { return; } this.group = gid; this.lstChoices.children.forEach( _node => { let focus = ( _node.name == 'c' + gid ); nx.gui.setActive( _node, "focus", focus ); } ); }, // 点击召唤 onTouchSummon: function() { if( !nx.dt.numPositive( this.group ) ) { 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 } ); } } ); }, } );