/****************************************************************** * * 新皮肤获取提示 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const NxSpine = require( "nx.fx.spine" ); const HeroController = require( "hero_controller" ); // 准备动画 const EID_READY = "E50093"; cc.Class( { extends: BridgeWindow, properties: { spReady: { default: null, type: NxSpine }, spRole: { default: null, type: NxSpine }, spMini: { default: null, type: NxSpine }, nodAttrs: { default: null, type: cc.Node }, nodName: { default: null, type: cc.Node }, nodTake: { default: null, type: cc.Node }, }, // 重载:参数打开 onOpenConfigs: function( _params ) { let sid = _params.skin_id; let cfgs = game.configs.partner_skin_data.data_skin_info[ sid ]; if( nx.dt.objEmpty( cfgs ) ) { nx.error( "无效皮肤:", sid ); this.scheduleOnce( () => { this.close(); }, 0.01 ); return; } this.skin = cfgs; this.startShow(); }, // 展示 startShow: function() { // 动画 let anim = nx.gui.getComponent( this, "", cc.Animation ); if( anim ) { anim.play( "anim_show" ); } // 角色 this.scheduleOnce( () => { this.showRole(); }, 0.2 ); // 名字 nx.gui.setString( this.nodName, "txt", nx.text.getKey( this.skin.skin_name ) ); // 属性 let attrs = this.skin.skin_attr || []; nx.gui.setActive( this.nodAttrs, "", nx.dt.arrNEmpty( attrs ) ); if( nx.dt.arrNEmpty( attrs ) ) { let chds = this.nodAttrs.children; nx.gui.gocChildren( this.nodAttrs, "", attrs.length, chds[ 0 ] ); for( let i = 0; i < attrs.length; ++i ) { nx.bridge.attrs.setAttribute( chds[ i ], attrs[ i ] ); } } }, // 角色展示 showRole: function() { let self = this; // 准备动画 let path = PathTool.getSpinePath( EID_READY, "action", false ); this.spReady.node.opacity = 255; this.spReady.load( path, ( _e ) => { if( !_e ) { self.spReady.action( "action", false ); } } ); // 1秒后渐变切换 this.scheduleOnce( () => { nx.tween.fadeOut( this.spReady, "", 0.5 ); }, 1 ); // 角色动画 path = PathTool.getSpinePath( this.skin.res_id, "show", false ); this.spRole.node.opacity = 0; this.spRole.stop(); this.spRole.load( path, ( _e ) => { if( !_e ) { this.spRole.action( "action1", true ); } else { this.spRole.stop(); } } ); // 迷你动画 path = PathTool.getSpinePath( this.skin.res_id, this.skin.res_id, false ); this.spMini.node.opacity = 0; this.spMini.stop(); this.spMini.load( path, ( _e ) => { if( !_e ) { this.spMini.action( "stand2", true ); } else { this.spMini.stop(); } } ); // 0.8秒后渐变切换 this.scheduleOnce( () => { nx.tween.fadeIn( this.spRole, "", 0.5 ); nx.tween.fadeIn( this.spMini, "", 0.5 ); }, 0.8 ); }, // 穿戴 onTouchTake: function() { let mod = HeroController.getInstance().getModel(); let bid = this.skin ? this.skin.bid : 0; let lst = mod ? mod.getHeroListByBid( bid ) : []; if( nx.dt.arrEmpty( lst ) ) { nx.tbox( "该伙伴还未获得" ); return; } // 最高战力排序 lst.sort( ( _a, _b ) => { return _b.power - _a.power; } ); // 打开伙伴详情页 nx.bridge.createPanel( "WndPartnerInfo", { hero_vo: lst[ 0 ], page: "skin" } ); this.close(); }, } );