133 lines
3.8 KiB
JavaScript
133 lines
3.8 KiB
JavaScript
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* 抽卡召唤动画卡片
|
|
*
|
|
******************************************************************/
|
|
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const SummonMod = require( "summon.mod" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
spFrame: { default: null, type: NxSpine },
|
|
},
|
|
|
|
// 翻卡
|
|
flip: function( _info ) {
|
|
|
|
let key = `${ _info.partner_bid }_${ _info.init_star }`;
|
|
let base = game.configs.partner_data.data_partner_base[ _info.partner_bid ];
|
|
let info = gdata( "partner_data", "data_partner_star", key );
|
|
if( !base || !info ) {
|
|
this.infos = null;
|
|
this.node.opacity = 0;
|
|
nx.error( "$FlipCard:无效伙伴", key );
|
|
return;
|
|
}
|
|
|
|
// 信息汇总
|
|
this.infos = {
|
|
bid: base.bid,
|
|
name: base.name,
|
|
camp: base.camp_type,
|
|
quality: base.quality,
|
|
star: info.star,
|
|
res: info.res_id,
|
|
args: nx.dt.objClone( _info ),
|
|
};
|
|
|
|
// 展示
|
|
this.clear();
|
|
this.show();
|
|
},
|
|
|
|
// 卡片清理
|
|
clear: function() {
|
|
|
|
nx.gui.setSpriteFrame( this, "camp", null );
|
|
nx.gui.setSpriteFrame( this, "star", null );
|
|
nx.gui.setSpriteFrame( this, "mask/img", null );
|
|
nx.gui.setSpriteFrame( this, "qa", null );
|
|
nx.gui.setSpriteFrame( this, "bg", null );
|
|
},
|
|
|
|
// 展示
|
|
show: function() {
|
|
|
|
this.node.opacity = 255;
|
|
|
|
// 阵营标记
|
|
let path = cc.path.join( "coms/images", "camps" + this.infos.camp );
|
|
nx.gui.setSpriteFrame( this, "camp", path );
|
|
|
|
// 星级
|
|
path = cc.path.join( "coms/images", "star" + this.infos.star );
|
|
nx.gui.setSpriteFrame( this, "star", path );
|
|
|
|
// 角色
|
|
path = cc.path.join( "resDB/models", this.infos.res, "half_show2" );
|
|
nx.gui.setSpriteFrame( this, "mask/img", path, ( _ret ) => {
|
|
if( !_ret ) {
|
|
nx.gui.setSpriteFrame( this, "mask/img", "resDB/empty/half_show2" );
|
|
}
|
|
} );
|
|
|
|
// 品质&&背景&&边框
|
|
let qa = "";
|
|
let showqa = "";
|
|
let frame = "";
|
|
let bg = cc.path.join( "prefab/summon/animation/images", "bg3" );
|
|
if( this.infos.star >= 5 ) {
|
|
// SSR
|
|
|
|
bg = cc.path.join( "prefab/summon/animation/images", "bg4" );
|
|
switch( this.infos.quality ){
|
|
case 6 : { showqa = "mk_partner_qa6" };break;
|
|
case 5 : { showqa = "mk_partner_qa5" };break;
|
|
case 4 : { showqa = "mk_partner_qa4" };break;
|
|
case 3 : { showqa = "mk_partner_qa3" };break;
|
|
}
|
|
|
|
qa = cc.path.join( "coms/images", showqa );
|
|
frame = cc.path.join( "prefab/summon/animation/spines/ssr/action" );
|
|
} else if( this.infos.star == 4 ) {
|
|
// SR
|
|
qa = cc.path.join( "coms/images", "mk_partner_qa3" );
|
|
frame = cc.path.join( "prefab/summon/animation/spines/sr/action" );
|
|
}
|
|
|
|
nx.gui.setSpriteFrame( this, "qa", qa );
|
|
nx.gui.setSpriteFrame( this, "bg", bg );
|
|
|
|
if( nx.dt.strEmpty( frame ) ) {
|
|
this.spFrame.stop();
|
|
}
|
|
else {
|
|
this.spFrame.play( frame, "action", ( _key ) => {
|
|
if( _key == "complete" ) {
|
|
this.spFrame.action( "action2", true );
|
|
}
|
|
}, false );
|
|
}
|
|
|
|
},
|
|
|
|
// 点击
|
|
onTouch: function() {
|
|
|
|
if( nx.dt.objEmpty( this.infos ) ||
|
|
nx.dt.objEmpty( this.infos.args ) ) {
|
|
return;
|
|
}
|
|
|
|
let SC = SummonMod.getInstance();
|
|
let partners = [ this.infos.args ];
|
|
SC.openSummonGainShowWindow( true, partners );
|
|
},
|
|
|
|
} );
|