/****************************************************************** * * 行星武器奖励弹窗 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const PathTool = require( "pathtool" ); const ItemExpand = require( "nx.fx.sv.expand" ); const StoneDungeonController = require( "stone_dungeon_controller" ); const StoneDungeonEvent = require( "stone_dungeon_event" ); const RoleController = require( "role_controller" ); const TipsController = require( "tips_controller" ); const NxSpine = require("nx.fx.spine"); cc.Class( { extends: BridgeWindow, properties: { list: { default: null, type: ItemExpand }, tab_list: { default: null, type: ItemExpand }, textCount: { default: null, type: cc.RichText }, nodClear: { default:null, type:cc.Node }, roleSp:{ default: null, type: NxSpine } }, onLoad() { this.ctrl = StoneDungeonController.getInstance(); this.model = this.ctrl.getModel(); this.role_vo = RoleController.getInstance().getRoleVo(); this.first_come_in = true this.cur_index = 1 // this.tab_list = [] this.bindGEvent( StoneDungeonEvent.Update_StoneDungeon_Data, this.updateDungeonData.bind( this ) ); }, updateDungeonData() { this.changeDungeonData( this.cur_index, 1 ); this.first_come_in = false; this.redPointStatus(); }, // 重载:参数打开 onOpenConfigs: function(params) { let tab_index = params.index || 0; this.ctrl.send13030(); var list = game.configs.dungeon_stone_data.data_const.dungeon_type.val var tab = []; for( var i = 0; i < list.length; i++ ) { tab.push( { id: list[ i ] } ); } this.tab_list.rebuild( tab ); this.tab_list.addFocus( tab_index ); this.setTipStatus(); let eff_path = PathTool.getSpinePath("H30051","show",false); this.roleSp.load(eff_path,(e)=>{ if(!e){ this.roleSp.action("action1",true); }else{ this.roleSp.stop(); } }); }, setTipStatus(){ }, onPreClosed: function() { this.list.rebuild( [] ); this.tab_list.rebuild( [] ); }, onFocusTabItem( _item ) { // 空 if( nx.dt.objEmpty( _item ) || nx.dt.objEmpty( _item.mdata ) ) { return; } if( this.cur_index == _item.mdata.id ) return; // 聚焦 this.tab_list.cleanFocus(); this.tab_list.addFocus( _item.index ); // this.model.setCurChangeSweep( _item.mdata.id ); this.cur_index = _item.mdata.id; this.changeDungeonData( _item.mdata.id ) }, // 红点 redPointStatus: function() { for(let i=1;i<=5;i++){ let index = i; var change_count = this.model.getChangeSweepCount( index ); if( change_count >= 2 ) { let key = cc.js.formatStr("pve.dungeon.%s",index); nx.mTip.openTip(key,false); } else { let key = cc.js.formatStr("pve.dungeon.%s",index); nx.mTip.openTip(key,true); } } }, updateClearStatus: function(data){ let is_clear = false; for( var i in data ) { var clearance = this.model.getPassClearanceID( data[ i ].id ); if( this.role_vo.max_power >= data[ i ].power ) { if( clearance && clearance.status == 1 ) { is_clear = true; } } } nx.gui.setActive( this.nodClear, "on", is_clear ); nx.gui.setActive( this.nodClear, "off", !is_clear ); }, changeDungeonData: function( index, flag ) { this.unscheduleAllCallbacks(); index = game.configs.dungeon_stone_data.data_type_open[ index ].id || 1; var change_count = this.model.getChangeSweepCount( index ); var str = ""; var free_count = 1; //1:还有次数 if( change_count >= 2 ) { free_count = 0; if( change_count >= game.configs.dungeon_stone_data.data_buy[ index ].length ) { str = cc.js.formatStr( nx.text.getKey( "lab_stone_dungeon_window_tip1" ) ) } else { var vip_count = 1; let cost = 0; for( var i in game.configs.dungeon_stone_data.data_buy[ index ] ) { if( game.configs.dungeon_stone_data.data_buy[ index ][ i ].vip <= this.role_vo.vip_lev ) { vip_count = i; cost = game.configs.dungeon_stone_data.data_buy[ index ][ i ].cost; } } var remain_num = vip_count - change_count; if( remain_num <= 0 ) { remain_num = 0 } this.remian_num = remain_num; str = cc.js.formatStr( nx.text.getKey( "lab_stone_dungeon_window_tip2" ), remain_num, cost ) } let key = cc.js.formatStr("pve.dungeon.%s",index); nx.mTip.openTip(key,false); } else { this.remian_num = game.configs.dungeon_stone_data.data_const.free_num.val - change_count; str = cc.js.formatStr( nx.text.getKey( "lab_stone_dungeon_window_tip3" ), game.configs.dungeon_stone_data.data_const.free_num.val - change_count ) let key = cc.js.formatStr("pve.dungeon.%s",index); nx.mTip.openTip(key,true); } this.textCount.string = str; var data_info = []; for( var i in game.configs.dungeon_stone_data.data_award_list ) { for( var m in game.configs.dungeon_stone_data.data_award_list[ i ] ) { if( game.configs.dungeon_stone_data.data_award_list[ i ][ m ].dun_type == index ) { data_info.push( game.configs.dungeon_stone_data.data_award_list[ i ][ m ] ); } } } data_info.sort( function( a, b ) { return a.id - b.id; } ); var title_pos = this.getPoerTitle( data_info ) change_count = change_count + 1; var temp_arr = Object.keys( game.configs.dungeon_stone_data.data_buy[ index ] ); if( change_count >= temp_arr.length ) { change_count = temp_arr.length; } var tab = { title_pos: title_pos, //推荐位置 count: free_count, //免费次数 expend: game.configs.dungeon_stone_data.data_buy[ index ][ change_count ].cost, //消耗钻石 } let go = 0; let list = []; for( let j in data_info ) { let data = {}; data.info = data_info[ j ]; data.tab = tab; list.push( data ); if( data.info.difficulty == data.tab.title_pos ){ go = parseInt(( data.info.id - 1 ) % 100 ) } } this.list.freshRange( 0, true ); this.list.rebuild( list ); this.updateClearStatus(data_info);//更新一下扫荡状态 let cmp = nx.gui.getComponent( this.list.node, "scoreView", cc.ScrollView ); if( cmp ) { cmp.scrollToTop( 0.0001 ); let posp = cc.v2( 0, ( go ) * 150 ); // cmp.setContentPosition( posp ); cmp.scrollToOffset( posp, 0.02 ); } // scrollTo // if( this.vip < 5 ){ // 引导辅助 if( nx.bridge.plot && nx.bridge.plot.isDoing() ) { this.positionPlotCells(); } }, // 获取推荐角标 getPoerTitle: function( data ) { var num = -1; var totle = data.length; for( var i in data ) { var clearance = this.model.getPassClearanceID( data[ i ].id ); if( this.role_vo.max_power >= data[ i ].power ) { if( clearance && clearance.status == 1 ) { num = parseInt( i ); } } } if( num + 1 >= totle ) { num = totle; } else { for( var i in data ) { if( this.role_vo.max_power >= data[ i ].power ) { num = parseInt( i ) + 1; } } // if( data[ num + 1 ] && this.role_vo.max_power >= data[ num + 1 ].power && this.role_vo.lev >= data[ num + 1 ].lev_limit ) { // num = num + 2; // } else { // return num + 1; // } } return num; }, // 规则说明 onTouchTip: function() { let TC = TipsController.getInstance(); if( TC ) { let txt = game.configs.dungeon_stone_data.data_const.desc_rule; TC.showTextPanel( "tip", txt.desc ); } }, onClickAllClear() { if(this.model.getCurChangeSweep() == null ) return; if( this.remain_num < 1 ) { return nx.tbox( "lab_stone_dungeon_window_tip1" ); } this.ctrl.send13032( this.model.getCurChangeSweep(), this.remian_num ); }, // ============================================ // 引导辅助 // ============================================ // 定位副本輔助热区 positionPlotCells: function() { let children = this.list.bindSCV.content.children; let node = children[ 0 ]; if( !node ) { nx.error( "$Dispatch:定位第一个派遣订单失败!" ); node = children[ 0 ]; if( !node ) { return; } } let cell = nx.gui.find( this, "plotCell" ); let btn = node.svItem.btnChange; let pos = btn.convertToWorldSpaceAR( cc.Vec2.ZERO ); cell.position = cell.parent.convertToNodeSpaceAR( pos ); cell.width = btn.width; cell.height = btn.height; cell.svItem = node.svItem; }, // 点击金币副本第一关挑战 onTouchFirstGolden: function() { let cell = nx.gui.find( this, "plotCell" ); if( cell && cell.svItem ) { cell.svItem.onClickChange(); } }, } );