Files
fc/dev/project/assets/Scripts/mod/partner/wings/cmp/cmp.wing.upgrade.js
T
2026-05-23 22:10:14 +08:00

171 lines
5.4 KiB
JavaScript

/******************************************************************
*
* 僚机进阶界面
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const ElfinController = require( "elfin_controller" );
const BackpackController = require( "backpack_controller" );
cc.Class( {
extends: BridgeWindow,
properties: {
lstProps: { default: null, type: cc.Node },
nodSkill: { default: null, type: cc.Node },
lstNeeds: { default: null, type: cc.Node },
},
onLoad: function() {
this.fresh();
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
},
// 刷新
fresh: function( ) {
let EC = ElfinController.getInstance();
let model = EC.getModel();
if( model ){
let wingData = model.getElfinTreeData();
let cbc = game.configs.sprite_data.data_tree_step[ wingData.break_lev ];
let nbc = game.configs.sprite_data.data_tree_step[ wingData.break_lev + 1 ];
// 如果当前的突破数据不存在 关闭
if( nx.dt.objEmpty( cbc ) || nx.dt.objEmpty( nbc ) ) {
this.scheduleOnce( () => {
this.close();
}, 0.03 );
return;
}
// 属性 数据刷新
// 首位为等级
let chds = this.lstProps.children;
let first = chds[ 0 ];
if( first ) {
nx.gui.setSpriteFrame( first, "icon", null );
nx.gui.setString( first, "name", nx.text.getKey( "Level" ) );
nx.gui.setString( first, "from", cbc.lev_max );
nx.gui.setString( first, "to", nbc.lev_max );
}
// 其他属性
for( let i = 1; i < chds.length; ++i ) {
let node = chds[ i ];
let att = nbc.all_attr[ i - 1 ];
if( !att ) {
node.active = false;
continue;
}
node.active = true;
let id = att[ 0 ];
let icon = cc.path.join( "coms/images", "ico_" + id );
nx.gui.setSpriteFrame( node, "icon", icon );
let name = game.configs.attr_data.data_key_to_name[ id ];
nx.gui.setString( node, "name", nx.text.getKey( name ) );
if( id == "hp_max" ) {
id = "hp";
}
if( !wingData[ id ] ) {
node.active = false;
continue;
}
nx.gui.setString( node, "from", wingData[ id ] );
nx.gui.setString( node, "to", wingData[ id ] + att[ 1 ] || 0 );
}
// 解锁新机位
// nx.gui.setActive( this.nodSkill, "icon", wingData.break_lev < 3 );
nx.gui.setActive( this.nodSkill, "max", false );
nx.gui.setString( this.nodSkill, "name", wingData.break_lev < 3 ? nx.text.format( "tip_FortressLevel_Unlocked", nbc.count, nbc.count + 1 ) : nx.text.getKey( "tip_FortressLevel_UnlockedAll" ) );
// 消耗
this.needs = [];
if( nx.dt.arrEmpty( cbc.expend ) ) {
// 无消耗
nx.gui.hideAllChildren( this.lstNeeds );
}
else {
let model = BackpackController.getInstance().getModel();
let chds = this.lstNeeds.children;
for( let i = 0; i < chds.length; ++i ) {
let node = chds[ i ];
let info = cbc.expend[ i ];
if( !info ) {
node.active = false;
continue;
}
node.active = true;
let cmp = node.getComponent( "cmp.item.base" );
if( cmp ){
cmp.setData( info[ 0 ]);
}
// let cfg = Utils.getItemConfig( info[ 0 ] );
// nx.bridge.setIconS( node, "icon", cfg.icon );
let have = model.getItemNumByBid( info[ 0 ] );
let str = cc.js.formatStr( "%s/%s", nx.dt.shortCount( have ), Utils.getMoneyString( info[ 1 ] ) );
nx.gui.setString( node, "count", str );
let clr = ( have >= info[ 1 ] ) ? cc.Color.WHITE : cc.Color.RED;
nx.gui.setColor( node, "count", clr );
// 缺少记录
if( have < info[ 1 ] ) {
this.needs.push( info[ 0 ] );
}
}
}
}
},
// 点击确认
onTouchConfirm: function() {
// 缺材料
if( nx.dt.arrNEmpty( this.needs ) ) {
let expend_item_cfg = gdata( "item_data", "data_unit1", this.needs[ 0 ], false );
nx.tbox( nx.text.format( nx.text.getKey( "lab_hero_break_window_tip1" ), expend_item_cfg.name ) );//Utils.TI18N("物品[" + expend_item_cfg.name + "]不足"));
BackpackController.getInstance().openTipsSource( true, this.needs[ 0 ] );
this.close();
return;
}
// 进阶
let EC = ElfinController.getInstance();
if( EC ){
EC.sender26512();
this.close();
}
},
} );