114 lines
3.6 KiB
JavaScript
114 lines
3.6 KiB
JavaScript
|
|
const BackPackConst = require( "backpack_const" );
|
||
|
|
const HeroCalculate = require("hero_calculate");
|
||
|
|
const GoodsVo = require( "goods_vo" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: cc.Component,
|
||
|
|
|
||
|
|
properties: {},
|
||
|
|
|
||
|
|
// 载入
|
||
|
|
onLoad: function() {
|
||
|
|
},
|
||
|
|
|
||
|
|
// 置空
|
||
|
|
setEmpty: function() {
|
||
|
|
|
||
|
|
nx.gui.setActive( this, "empty", true );
|
||
|
|
nx.gui.setActive( this, "content", false );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 设置道具
|
||
|
|
// @ 返回true:需要显示
|
||
|
|
setData: function( _item, _config, _fromBag ) {
|
||
|
|
|
||
|
|
// 全隐藏
|
||
|
|
if( !_item || !_config ) {
|
||
|
|
this.setEmpty();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setActive( this, "empty", false );
|
||
|
|
let content = nx.gui.setActive( this, "content", true );
|
||
|
|
|
||
|
|
// 名字
|
||
|
|
nx.gui.setString( content, "name", nx.text.getKey( _config.name ) );
|
||
|
|
|
||
|
|
// 类型
|
||
|
|
nx.gui.setString( content, "type/txt", nx.text.getKey( _config.type_desc ) );
|
||
|
|
|
||
|
|
// 品质
|
||
|
|
let qa = _item.quality || _config.quality;
|
||
|
|
let path = cc.path.join( "coms/images", "bar_qa" + qa );
|
||
|
|
let qa_path = cc.path.join( "coms/images", "bg_qa" + qa );
|
||
|
|
nx.gui.setSpriteFrame( content, "bg", path );
|
||
|
|
if( typeof( _fromBag ) === 'string' ){
|
||
|
|
if( _fromBag == "bag" ){
|
||
|
|
nx.gui.setSpriteFrame( content, "qa", "" );
|
||
|
|
}else{
|
||
|
|
nx.gui.setSpriteFrame( content, "qa", "" );
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// 图标
|
||
|
|
nx.bridge.setIcon( content, "qa/icon", _config.icon );
|
||
|
|
|
||
|
|
// 星级
|
||
|
|
let star = _config.eqm_star || _config.eqm_jie;
|
||
|
|
let good = nx.dt.numPositive( star, false );
|
||
|
|
if( good ) {
|
||
|
|
path = cc.path.join( "coms/images", "star" + star );
|
||
|
|
nx.gui.setSpriteFrame( content, "qa/stars", path );
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
nx.gui.setSpriteFrame( content, "qa/stars", null );
|
||
|
|
}
|
||
|
|
|
||
|
|
// 附加说明
|
||
|
|
let vars = nx.gui.hideAllChildren( content, "vars" );
|
||
|
|
if( vars ) {
|
||
|
|
|
||
|
|
|
||
|
|
let new_score = 0;
|
||
|
|
if( nx.dt.arrNEmpty( _item.holy_eqm_attr ) && typeof( _fromBag ) === 'string' && _fromBag == "partner" ){
|
||
|
|
let holy_eqm_attr = _item.holy_eqm_attr
|
||
|
|
let new_holy_eqm_attr = [];
|
||
|
|
|
||
|
|
for (let i = 0; i < holy_eqm_attr.length; i++) {
|
||
|
|
let attr = holy_eqm_attr[i];
|
||
|
|
if( attr ){
|
||
|
|
let title = game.configs.attr_data.data_id_to_key[attr.attr_id];
|
||
|
|
new_holy_eqm_attr.push({ attr_key: title, attr_val: attr.attr_val })
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
new_score = HeroCalculate.getInstance().holyEquipMentPower(new_holy_eqm_attr) || 0;
|
||
|
|
|
||
|
|
}
|
||
|
|
// 评分
|
||
|
|
let score = ( _item.all_score + new_score ) || ( _config.all_score + new_score ) ;
|
||
|
|
if( nx.dt.numPositive( score, false ) ) {
|
||
|
|
nx.gui.setActive( vars, "score", true );
|
||
|
|
nx.gui.setString( vars, "score/txt", score );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// UseType描述头区分
|
||
|
|
let tdesc = _config.use_desc;
|
||
|
|
if( nx.dt.strNEmpty( tdesc ) ) {
|
||
|
|
nx.gui.setActive( vars, "use", true );
|
||
|
|
let elfin = ( _config.type == BackPackConst.item_type.ELFIN );
|
||
|
|
nx.gui.setString( vars, "use/tip", nx.text.getKey( elfin ? "UseElfin" : "UseTo" ) );
|
||
|
|
nx.gui.setString( vars, "use/txt", nx.text.getKey( tdesc ) );
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|