Files
fc/dev/project/assets/Scripts/mod/partner/cmps/skill/cmp.partner.skill.uplv.wnd.js
T

91 lines
2.5 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 伙伴技能升级界面
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const BackPackController = require( "backpack_controller" );
cc.Class( {
extends: BridgeWindow,
properties: {
nodSks: { default: null, type: cc.Node },
nodNeeds: { default: null, type: cc.Node },
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this.partner = _params.hero_vo;
this.sid = _params.skill_id;
this.cb = _params.cb;
this.fresh();
},
// 刷新
fresh: function() {
// 配置获取
const cfgs = game.configs.partner_skill_data.data_partner_skill_level[ this.sid ];
if( nx.dt.objEmpty( cfgs ) || !nx.dt.numPositive( cfgs.next_id, false ) ) {
nx.error( "无效技能升级配置:", this.sid );
this.scheduleOnce( () => { this.close(); }, 0.03 );
return;
}
// 技能信息
let cur = nx.gui.getComponent( this.nodSks, "from/icon", "cmp.skill.base" );
cur.setData( this.sid );
let tar = nx.gui.getComponent( this.nodSks, "to/icon", "cmp.skill.base" );
tar.setData( cfgs.next_id );
let BC = BackPackController.getInstance();
let BM = BC.getModel();
// 耗材
this.enough = true;
let expend = cfgs ? cfgs.expend : [];
let temp = nx.gui.find( this.nodNeeds, "list" );
for( let i = 0; i < temp.children.length; ++i ) {
let item = temp.children[ i ];
let info = expend[ i ];
if( !info ) {
nx.gui.setActive( item, "", false );
continue;
}
nx.gui.setActive( item, "", true );
let cmp = nx.gui.getComponent( item, "", "cmp.item.base" );
if( cmp ) {
cmp.setData( info[ 0 ] );
let hcnt = BM.getItemNumByBid( info[ 0 ] );
nx.gui.setString( cmp, "count", nx.dt.shortCount( info[ 1 ] ) + "/" + nx.dt.shortCount( hcnt ) );
let eno = ( hcnt >= info[ 1 ] );
nx.gui.setColor( cmp, "count", eno ? cc.Color.WHITE : cc.Color.RED );
if( !eno ) {
this.enough = false;
}
}
}
},
// 点击确认
onTouchConfirm: function() {
// 返回
nx.dt.fnInvoke( this.cb, true );
this.close();
},
} );