/****************************************************************** * * 伙伴获得展示界面 * ******************************************************************/ const BridgeWindow = require( "bridge.window" ); const NxSpine = require( "nx.fx.spine" ); const TipsController = require( "tips_controller" ); const HeroConst = require( "hero_const" ); const HeroController = require( "hero_controller" ); // 准备动画 const EID_READY = "E50093"; cc.Class( { extends: BridgeWindow, properties: { spReady: { default: null, type: NxSpine }, spRole: { default: null, type: NxSpine }, nodInfo: { default: null, type: cc.Node }, nodProps: { default: null, type: cc.Node }, nodNew: { default: null, type: cc.Node }, lstSkills: { default: null, type: cc.Node }, spBg: { default: null, type: cc.Node }, spBars: { default: [], type: cc.Node }, }, // 重载:参数打开 onOpenConfigs: function( _params ) { /** 单结构 * init_star,is_chips,partner_bid,status */ this.queue = _params.bids; this.cb = _params.cb; // 空展示 if( nx.dt.arrEmpty( this.queue ) ) { this.scheduleOnce( () => { this.close(); }, 0.05 ); } // 记录是否是新卡 const Model = HeroController.getInstance().getModel(); for( let i in this.queue ) { let bid = this.queue[ i ].partner_bid; let star = Model.getHadHeroStarBybid( bid ); this.queue[ i ].had = nx.dt.numPositive( star, false ); } // 展示下一个 this.showNext(); }, // 展示下一个 showNext: function() { // 空了 if( nx.dt.arrEmpty( this.queue ) ) { nx.dt.fnInvoke( this.cb ); this.close(); return; } // 弹出 let data = this.queue.shift(); if( nx.dt.objEmpty( data ) || !nx.dt.numPositive( data.partner_bid, false ) ) { nx.error( "无效伙伴展示!" ); this.showNext(); return; } // 动画 let anim = nx.gui.getComponent( this, "", cc.Animation ); if( anim ) { anim.play( "anim_show" ); } // 配置获取 const bid = data.partner_bid; const cfgs = game.configs.partner_data.data_partner_base[ bid ]; const star = data.init_star || ( cfgs ? cfgs.star : 0 ); const scfgs = gdata( "partner_data", "data_partner_star", `${ bid }_${ star }` ); if( nx.dt.objEmpty( scfgs ) ) { nx.error( "无效伙伴展示,配置无效:", `${ bid }_${ star }` ); this.showNext(); return; } // 刷新 this.had = data.had; this.star = star; this.cfgs = cfgs; this.scfgs = scfgs; this.fresh(); // 如果空了刷新一次图鉴 if( nx.dt.arrEmpty( this.queue ) ) { const HC = HeroController.getInstance(); HC.sender11040(); } }, // 刷新当前信息 fresh: function() { // 新卡 nx.gui.setActive( this.nodNew, "", !this.had ); // 角色 this.scheduleOnce( () => { this.showRole(); }, 0.2 ); // 名字 nx.gui.setString( this.nodInfo, "name", this.cfgs.name ); // 品质 let path = cc.path.join( "coms/images", "mk_partner_qa" + this.cfgs.quality ); nx.gui.setSpriteFrame( this.nodInfo, "qa", path ); // 阵营 path = cc.path.join( "prefab/partner/ui/camp" + this.cfgs.camp_type ); nx.gui.setSpriteFrame( this.nodInfo, "camp", path ); // 星级 path = cc.path.join( "coms/images", "star" + this.star ); nx.gui.setSpriteFrame( this.nodInfo, "stars", path ); // 职业 let career = this.cfgs.type || 4; let icon = cc.path.join( "coms/images", "career" + career ); let name = nx.text.getKey( HeroConst.CareerName[ career ] ) || nx.text.getKey( "lab_none" ); nx.gui.setActive( this.nodProps, "career", true ); nx.gui.setString( this.nodProps, "career/txt", name ); nx.gui.setSpriteFrame( this.nodProps, "career/icon", icon ); // 定位 let pos = this.cfgs.pos || this.cfgs.introduce_str; nx.gui.setString( this.nodProps, "pos", nx.text.getKey( pos ) ); // 技能 nx.gui.setActive( this.lstSkills, "", true ); const chds = this.lstSkills.children; for( let i = 0; i < chds.length; ++i ) { // 技能数组[0]为普攻,直接忽略,最多4个技能 let item = chds[ i ]; let sifo = this.scfgs.skills[ i + 1 ]; if( !sifo ) { item.active = false; continue; } item.active = true; let cmp = nx.gui.getComponent( item, "", "cmp.skill.base" ); if( cmp ) { cmp.setData( sifo[ 1 ] ); } } // SSR皮肤切换 let key = "Normal"; if( this.cfgs.quality >= 4 ) { key = "SSR"; } else if( this.cfgs.quality >= 3 ) { key = "SR"; } let bg = cc.path.join( "prefab/summon/images", "bg" + key ); nx.gui.setSpriteFrame( this.spBg, "", bg ); let tiao = cc.path.join( "prefab/summon/images", "tiao" + key ); this.spBars.forEach( _bar => { nx.gui.setSpriteFrame( _bar, "", tiao ); } ); }, // 查看介绍 onTouchStory: function() { const TC = TipsController.getInstance(); let txt = nx.text.getKey( "story" + this.cfgs.bid ); TC.showTextPanel( "PartnerStory", txt ); }, // 点击下一个 onTouchNext: function() { this.showNext(); }, // 角色准备 readyRole: function() { this.spRole.stop(); let self = this; let path = PathTool.getSpinePath( EID_READY, "action", false ); this.spRole.load( path, ( _e ) => { if( _e ) { self.showRole(); return; } self.spRole.action( "action", false, ( _key ) => { if( _key == "complete" ) { self.showRole(); } } ); } ); }, // 角色展示 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.scfgs.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(); } } ); // 0.8秒后渐变切换 this.scheduleOnce( () => { nx.tween.fadeIn( this.spRole, "", 0.5, () => { this.playVoice(); } ); }, 0.8 ); }, // 播放语音 playVoice: function() { // 语音 SR&&SSR let cfg = game.configs.partner_data.data_partner_base[ this.cfgs.bid ]; if( nx.dt.objEmpty( cfg ) || nx.dt.strEmpty( cfg.voice ) ) { return; } let path = cc.path.join( "resDB/models", this.scfgs.res_id, "voice" ); nx.audio.playVoice( path ); }, } );