147 lines
3.8 KiB
JavaScript
147 lines
3.8 KiB
JavaScript
const ItemBase = require( "cmp.item.base" );
|
|
const BackPackConst = require( "backpack_const" );
|
|
const BackPackController = require( "backpack_controller" );
|
|
const BTT = BackPackConst.item_type;
|
|
|
|
/**********
|
|
*
|
|
* 僚机展示
|
|
*/
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
|
|
nodLock:{ default:null, type : cc.Node },
|
|
},
|
|
|
|
// 重载:刷新
|
|
freshAll: function() {
|
|
|
|
this._super();
|
|
this.focus = false;
|
|
// this.setLocked( true );
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
|
|
this.outFocus();
|
|
this.setQuality( -1 );
|
|
this.setIcon( 0 );
|
|
this.setName( nx.text.getKey( "NoneWingsOn" ) );
|
|
this.setDescribe( "" );
|
|
this.setStars( 0 );
|
|
this.freshLT();
|
|
this.freshRT();
|
|
nx.gui.setString( this.nodCount, "", "" );
|
|
|
|
},
|
|
|
|
// 单设:数量
|
|
setCount: function( _count ) {
|
|
|
|
// 碎片获取合成配置,显示进度
|
|
if( this.nodCount && this.info && this.info.type == BTT.PARTNER_DEBRIS ) {
|
|
let cfg = gdata( "partner_data", "data_get_compound_info", this.info.item_id );
|
|
if( nx.dt.objNEmpty( cfg ) ) {
|
|
this.nodCount.string = _count + "/" + cfg.num;
|
|
return;
|
|
}
|
|
}
|
|
if( this.nodCount && this.info && this.info.type == BTT.ELFIN_EGG ) {
|
|
// let cfg = gdata( "partner_data", "data_get_compound_info", this.info.item_id );
|
|
let BC = BackPackController.getInstance();
|
|
|
|
let count = BC.getModel().getItemNumByBid( this.info.item_id );
|
|
// if( nx.dt.objNEmpty( cfg ) ) {
|
|
this.nodCount.string = count + "/" + 1;
|
|
return;
|
|
// }
|
|
}
|
|
|
|
this._super( _count );
|
|
},
|
|
|
|
// 单设:品质
|
|
setQuality: function( _qa ) {
|
|
|
|
if( this.nodBG ) {
|
|
let qa = null;
|
|
if( nx.dt.numPositive( _qa ) ) {
|
|
switch( _qa ){
|
|
case 2 : { qa = cc.path.join( "prefab/partner/wing/ui/partner_82" ); } break;
|
|
case 3 : { qa = cc.path.join( "prefab/partner/wing/ui/partner_57" ); } break;
|
|
case 4 : { qa = cc.path.join( "prefab/partner/wing/ui/partner_83" ); } break;
|
|
}
|
|
|
|
}
|
|
nx.gui.setSpriteFrame( this.nodBG, "", qa );
|
|
}
|
|
},
|
|
|
|
// 左上角标更新
|
|
freshLT: function() {
|
|
|
|
if( !this.imgLT ) {
|
|
return;
|
|
}
|
|
|
|
let sf = null;
|
|
|
|
// 区别处理
|
|
if( nx.dt.objNEmpty( this.info ) ) {
|
|
|
|
// console.log( "当前的数据信息" + JSON.stringify( this.info ) );
|
|
// let cfg =
|
|
// 精灵等级
|
|
if( !sf && this.info.type == BackPackConst.item_type.ELFIN ) {
|
|
let sfg = gdata( "sprite_data","data_elfin_data", this.info.item_id );
|
|
if( sfg.skill ){
|
|
|
|
let data = gskilldata( 'data_get_skill', sfg.skill );
|
|
|
|
// console.log( "技能信息" + JSON.stringify( data ) );
|
|
sf = cc.path.join( "coms/images/ico_lv" + data.level );
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
nx.gui.setSpriteFrame( this.imgLT, "", sf );
|
|
|
|
},
|
|
|
|
// 单设:锁定
|
|
setLocked: function( _locked ) {
|
|
|
|
this.locked = !!_locked;
|
|
if( this.nodLock ){
|
|
nx.gui.setActive( this.nodLock, "", this.locked );
|
|
}
|
|
|
|
},
|
|
|
|
// 聚焦获得
|
|
onFocus: function() {
|
|
|
|
if( this.nodFocus ) {
|
|
this.nodFocus.node.active = true;
|
|
this.focus = true;
|
|
}
|
|
|
|
},
|
|
|
|
// 聚焦失去
|
|
outFocus: function() {
|
|
|
|
if( this.nodFocus ) {
|
|
this.nodFocus.node.active = false;
|
|
this.focus = false;
|
|
}
|
|
|
|
},
|
|
|
|
}); |