131 lines
3.2 KiB
JavaScript
131 lines
3.2 KiB
JavaScript
|
|
|
|
const ItemBase = require( "cmp.item.base" );
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
|
const TipsController = require("tips_controller");
|
|
const BackPackConst = require( "backpack_const" );
|
|
const BIT = BackPackConst.item_type;
|
|
|
|
cc.Class( {
|
|
|
|
extends: SVCItem,
|
|
|
|
properties: {
|
|
|
|
cmpItem: {
|
|
default: null,
|
|
type: ItemBase,
|
|
displayName: "图标"
|
|
},
|
|
|
|
},
|
|
|
|
// 数据重置
|
|
rebind: function( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
|
|
// 刷新
|
|
this.setData( _data );
|
|
|
|
},
|
|
|
|
// 重置
|
|
setData: function( _data, _count ) {
|
|
|
|
this.mdata = _data;
|
|
this.cmpItem.setData( _data, _count );
|
|
|
|
// 区别刷新
|
|
if( _data.type == BIT.ARTIFACTCHIPS ) {
|
|
this.freshArtifact();
|
|
} else {
|
|
this.freshEquipment();
|
|
}
|
|
|
|
},
|
|
|
|
// 神装刷新
|
|
freshArtifact: function() {
|
|
|
|
// 显隐控制
|
|
nx.gui.setActive( this, "level", false );
|
|
nx.gui.setActive( this, "score", false );
|
|
nx.gui.setActive( this, "skills", false );
|
|
|
|
// 刷新属性
|
|
let cmp = nx.gui.getComponent( this, "atts", "cmp.item.detail.prop.base" );
|
|
if( cmp ) {
|
|
cmp.setData( this.mdata, this.mdata.config, false );
|
|
}
|
|
|
|
// 刷新技能
|
|
let extra = this.mdata.extra;
|
|
if( nx.dt.arrNEmpty( extra ) ) {
|
|
|
|
// 统计
|
|
let sks = [];
|
|
for( let i in extra ) {
|
|
let ext = extra[i];
|
|
if( ext && ( ext.extra_k == 1 || ext.extra_k == 2 || ext.extra_k == 8 ) ) {
|
|
let cfg = gskilldata( "data_get_skill", ext.extra_v );
|
|
if( cfg ) {
|
|
sks.push( cfg );
|
|
}
|
|
}
|
|
}
|
|
|
|
if( nx.dt.arrNEmpty( sks ) ) {
|
|
const root = nx.gui.setActive( this, "skills", true );
|
|
const chds = root.children;
|
|
nx.gui.gocChildren( root, "", sks.length, chds[ 0 ] );
|
|
for( let i = 0; i < sks.length; ++i ) {
|
|
let sk = sks[i];
|
|
nx.gui.setString( chds[i], "", nx.text.format( "bracket", sk.name ) );
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 装备刷新
|
|
freshEquipment: function() {
|
|
|
|
// 显隐控制
|
|
nx.gui.setActive( this, "level", true );
|
|
nx.gui.setActive( this, "score", true );
|
|
nx.gui.setActive( this, "skills", false );
|
|
|
|
// 刷新
|
|
nx.gui.setString( this, "level/txt", this.mdata.lev );
|
|
nx.gui.setString( this, "score/txt", this.mdata.all_score );
|
|
|
|
// 刷新
|
|
let cmp = nx.gui.getComponent( this, "atts", "cmp.item.detail.prop.base" );
|
|
if( cmp ) {
|
|
cmp.setData( this.mdata, this.mdata.config, false );
|
|
}
|
|
},
|
|
|
|
// 点击装备
|
|
onTouchEquip: function() {
|
|
|
|
let svc = this.node.svc;
|
|
if( svc && svc.binder && svc.binder.onEquip ) {
|
|
svc.binder.onEquip( this.mdata );
|
|
}
|
|
|
|
},
|
|
|
|
onTouchIcon: function(){
|
|
|
|
const TC = TipsController.getInstance();
|
|
if( TC && this.mdata ) {
|
|
TC.showItemTips( this.mdata );
|
|
}
|
|
|
|
},
|
|
|
|
} );
|