Files
fc/dev/project/assets/Scripts/mod/backpack/cmps/cmp.item.detail.prop.suit.js
T

240 lines
7.9 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const PathTool = require( "pathtool" );
const BackPackConst = require( "backpack_const" );
const GoodsVo = require( "goods_vo" );
cc.Class( {
extends: cc.Component,
properties: {
nodList: {
default: null,
type: cc.Node,
displayName: "列表容器"
},
},
// 载入
onLoad: function() {
if( this.tween ){
this.tween.stop();
}
},
// 置空
setEmpty: function() {
this.suit_config = null;
nx.gui.hideAllChildren( this.nodList, "" );
},
// 设置道具
// @ 返回true:需要显示
setData: function( _item, _config, _fromBag ) {
// 全隐藏
if( !_item || !_config ) {
this.setEmpty();
return false;
}
// 获取配置
this.item = _item;
this.config = _config;
//判断是否需要展示套装属性
if( _config.eqm_set && this.config.eqm_set != 0 ) {
if( this.config.sub_type == BackPackConst.item_sub_type.HOLYEQUIPMENT ) { //神裝
this.suit_config = gdata( "partner_holy_eqm_data", "data_suit_info", this.config.eqm_set )
} else if( this.config.sub_type == BackPackConst.item_sub_type.EQUIPS ) {
this.suit_config = gdata( "partner_eqm_data", "data_eqm_suit", this.config.eqm_set )
}
else {
return false;
}
if( this.suit_config ) {
// need_show_suitattr = true
}
}
if( this.config.eqm_set == 0 ){
return;
}
let data = this.setSuitAttrInfo();
// let need_show_skill = data.show_skill_id;
// if (need_show_skill != null) {
// let config = gskilldata('data_get_skill', need_show_skill)
// if (config) {
// target_height = target_height + this.skill_panel_height
// if (this.skill_item == null) {
// this.skill_item = this.createSkillItem(this.skill_panel)
// }
// this.skill_item.skill.showLockIcon(false)
// this.skill_item.skill.setData(config)
// this.skill_item.desc.string = (config.des)
// } else {
// need_show_skill = false
// }
// }
// 统计主属性信息
let props = data;
// 空属性
if( nx.dt.arrEmpty( props ) ) {
this.setEmpty();
return false;
}
// 属性设置
const setProp = function( _node, _prop ) {
if( !_node || nx.dt.objEmpty( _prop ) ) {
return;
}
let res_path = null;
let name = "";
if( _prop.skill_desc ){
if( _prop.skill_desc.length == 1 ) {
res_path = PathTool.getAttrIconRes( _prop.attr[ 0 ] )
name = gdata( "attr_data", "data_key_to_name", _prop.attr[ 0 ] )
nx.gui.setActive( _node, "info/dot", true );
} else {
res_path = PathTool.getAttrIconRes( "skill" )
name = _prop.skill_desc[ 1 ] || nx.text.getKey( "描述信息無" );
nx.gui.setActive( _node, "info/dot", false );
}
}else{
if( _prop.attr.length > 1 ) {
res_path = PathTool.getAttrIconRes( _prop.attr[ 0 ] )
name = gdata( "attr_data", "data_key_to_name", _prop.attr[ 0 ] )
nx.gui.setActive( _node, "info/dot", true );
} else {
res_path = PathTool.getAttrIconRes( "skill" )
name = _prop.skill_desc[ 1 ] || nx.text.getKey( "描述信息無" );
nx.gui.setActive( _node, "info/dot", false );
}
}
nx.gui.setSpriteFrame( _node, "info/icon", res_path );
// nx.gui.setString( _node, "info/key", nx.dt.strCut( nx.text.getKey( name ), 8 ) );
if( nx.dt.strNEmpty( name ) ){
nx.gui.setStringRich( _node, "info/key", nx.text.getKey( name ) );
}
// nx.gui.setActive( _node, "info/key/show", false );
let val = BackPackConst.getAttrValue( _prop.attr[ 0 ], _prop.attr[ 1 ] )
if( !val ) {
val = "";
}
nx.gui.setString( _node, "info/val", val );
nx.gui.setString( _node, "suitname", nx.text.getKey( _prop.suit_name ) );
};
// 列表创建
const chds = this.nodList.children;
nx.gui.gocChildren( this.nodList, "", props.length, chds[ 0 ] );
for( let i = 0; i < props.length; ++i ) {
setProp( chds[ i ], props[ i ] );
}
return true;
},
// 设置套装
setSuitAttrInfo: function() {
if( this.config == null ) {
return -1
}
if( this.suit_config == null ) {
return -1
}
// var act_count = this.getEquipActiveCount()
// 按照套装排个序
this.suit_config.sort( function( a, b ) {
return a.num - b.num
} )
console.log( "当前的套装相关" + JSON.stringify( this.suit_config ) );
var name = null
var suit_list = []
for( let index = 0; index < this.suit_config.length; index++ ) {
const element = this.suit_config[ index ];
if( element ) {
if( name == null ) {
name = element.name;
}
if( element.attr || element.skill_id ) {
let i = index;
if( this.config.sub_type == BackPackConst.item_sub_type.HOLYEQUIPMENT ) { //神裝
let suit = {};
let eqm_set = null;
suit.count = element.num;
suit.attr = element.skill_id[ element.skill_id.length - 1 ];
eqm_set = element.id;
if( element.all_skill_desc ) {
suit.skill_desc = element.all_skill_desc[ element.all_skill_desc.length - 1 ];//神裝套裝描述
}
suit.suit_name = cc.js.formatStr( ( "%s(%s)" ), element.name, suit.count );
suit_list.push( suit );
}
if( element.attr ) {
if( this.config.sub_type == BackPackConst.item_sub_type.EQUIPS ) {
let suit = {};
let eqm_set = null;
suit.count = element.num;
suit.attr = element.attr[ element.attr.length - 1 ];
eqm_set = element.id;
suit.suit_name = cc.js.formatStr( ( "%s(%s)" ), element.name, suit.count );
suit_list.push( suit );
}
}
}
}
}
// var suit = suit_list[suit_list.length - 1];
// // 设置属性
// for (let index = 0; index < suit_list.length; index++) {
// const element = suit_list[index];
// if (typeof (element.attr) == "number") {
// if (suit.skill_desc[0] && suit.skill_desc[0] == 2) {
// show_skill_id = suit.attr
// }
// }
// }
return suit_list;
},
onTouchPropName: function( _node ){
let nod = nx.gui.find( _node, "show" );
nx.gui.setActive( nod, "", true );
nx.tween.fadeIn( nod, 0.3 );
this.tween = cc.tween( nod )
.to( 0.01, nod.parent.scaleX < 1 ? { scale: 1.4 } : { scale: 1 } )
.delay( 2 )
.call( ()=>{
nx.tween.fadeOut( nod, 0.3 );
} )
.start();
}
} );