/****************************************************************** * * 奖励弹窗 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const BackPackConst = require( "backpack_const" ); const FxSpine = require( "nx.fx.spine" ); cc.Class( { extends: BridgeWindow, properties: { spAnim: { default: null, type: FxSpine }, nodRewards: { default: null, type: cc.Node }, nodTouch: { default: null, type: cc.Node }, }, // 重载:参数打开 onOpenConfigs: function( _params ) { this.params = _params ? _params.list : null; /**** * awards":[{"item_bid":10040,"item_num":3},{"item_bid":111001,"item_num":1}]} */ // 判空 if( nx.dt.arrEmpty( this.params ) ) { this.close(); nx.error( "[REWARD]无效的道具表!" ); return; } this.items = []; this.sprites = []; for (let i = 0; i < this.params.length; i++) { let item = this.params[i]; let cfg = game.configs.sprite_data.data_elfin_data[item.item_bid]; if( !cfg ){ this.items.push( item ); }else{ this.sprites.push( item ); } } for (let j = 0; j < this.sprites.length; j++) { let sp = this.sprites[j]; let sfg = gdata( "sprite_data", "data_elfin_data", sp.item_bid ); let ifg = gdata( "item_data", "data_unit9", sp.item_bid ); if( ifg ){ nx.bridge.setIcon( this.nodRewards, "wing", ifg.imageid ); if( sfg ){ let skill = gdata( "skill_data4","data_get_skill",sfg.skill ); nx.gui.getComponent( this.nodRewards, "skill", "cmp.skill.base" ).setData( sfg.skill ); } nx.gui.setString( this.nodRewards, "name", ifg.name ) ; nx.gui.setString( this.nodRewards, "type", ifg.use_desc ) ; // console.log( JSON.stringify( ifg ) + "当前的奖励" + JSON.stringify( this.items[0] ) ); // self.scheduleOnce( () => { // nx.gui.setActive( self.nodSpecial, "", true ); // }, 0.2 ); } } nx.gui.setActive( this.nodRewards, "items", nx.dt.arrNEmpty( this.items ) ); nx.gui.gocChildren( this.nodRewards, "items/items", this.items.length ); let chd = nx.gui.find( this.nodRewards, "items/items" ).children; for (let l = 0; l < chd.length; l++) { let p = chd[l]; let cmp = p.getComponent( "cmp.item.base" ); if( this.items[l] ){ if( cmp ){ cmp.setData( this.items[l].item_bid ); } nx.gui.setString( p, "count", this.items[l].item_num ); } } nx.gui.setActive( this.nodRewards, "", false ); // 动画流程 this.doAnimation(); }, showRewards : function(){ nx.gui.setActive( this.nodSpecial, "", false ); }, // 动画流程 doAnimation: function() { this.spAnim.action( "action", false, ( _key, _name ) => { if( _key == "reward" ) { this.nodRewards.active = true; return; } // 第二阶段 if( _key == "complete" ) { this.spAnim.action( "action2", true ); return; } } ); }, } );