Files
fc/dev/project/assets/Scripts/mod/partner/cmps/skin/cmp.partner.skin.item.js
T

96 lines
2.3 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 伙伴皮肤项
*
******************************************************************/
const SkinWnd = require( "cmp.partner.skin" );
const HeroController = require( "hero_controller" );
// 聚焦偏移
const ON_Y = -30;
const OFF_Y = -20;
cc.Class( {
extends: cc.Component,
properties: {
bindWnd: { default: null, type: SkinWnd },
nodFocus: { default: null, type: cc.Node },
nodInfos: { default: null, type: cc.Node },
},
// 设置
setSkin: function( _index, _data ) {
// 重置
if( nx.dt.objEmpty( this.skin ) ) {
nx.gui.setActive( this.nodInfos, "lock", false );
nx.gui.setActive( this.nodInfos, "way", false );
this.setFocus( false );
}
this.index = _index;
this.skin = _data;
if( nx.dt.objEmpty( this.skin ) ) {
return;
}
// 图片
let path = cc.path.join( "resDB/models", this.skin.res_id, "half_show4" );
nx.gui.setSpriteFrame( this.nodInfos, "role/img", path, ( _ret ) => {
if( !_ret ) {
nx.gui.setSpriteFrame( node, "role/img", "resDB/empty/half_show4" );
}
} );
// 名字
let name = nx.text.getKey( this.skin.skin_name );
nx.gui.setString( this.nodInfos, "name", name );
// 获取途径
let way = nx.text.getKey( this.skin.source_tip );
nx.gui.setString( this.nodInfos, "way", way );
// 变量刷新
this.freshVars();
},
// 变量刷新
freshVars: function() {
let HC = HeroController.getInstance();
let HM = HC.getModel();
let lst = HM.hero_skin_list || {};
let have = nx.dt.numGood( lst[ this.skin.skin_id ] );
nx.gui.setActive( this.nodInfos, "lock", !have );
nx.gui.setActive( this.nodInfos, "way", !have );
},
// 聚焦
setFocus: function( _focus ) {
this.nodFocus.active = _focus;
this.nodInfos.y = _focus ? ON_Y : OFF_Y;
let clr = _focus ? new cc.color( "#21FFC6" ) : cc.Color.WHITE;
nx.gui.setColor( this.nodInfos, "way", clr );
},
// 点击
onTouch: function() {
if( this.nodFocus.active ) {
return;
}
this.bindWnd.setSkin( this.index );
},
} );