Files
fc/dev/project/assets/Scripts/mod/pray/cmp/cmp.holy.pray.uplev.js
T

121 lines
3.9 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const BridgeWindow = require( "bridge.window" );
const BackPackController = require( "backpack_controller" );
const PrayMod = require( "pray.mod" );
const HeavenEvent = require( "heaven_event" );
cc.Class({
extends: BridgeWindow,
properties: {
nodRate: { default: null, type: cc.Node },
nodMat: { default: null, type: cc.Node },
nodNowLevel: { default: null, type: cc.Node },
nodNextLevel: { default: null, type: cc.Node },
},
onLoad: function(){
this.bindGEvent( HeavenEvent.Update_Dial_Base_Data, this.freshInfo.bind( this) );
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this.freshInfo( _params );
},
freshInfo: function( _params ){
this.lev = _params.lev;
this.group_id = _params.group_id;
let ncfg = game.configs.holy_eqm_lottery_data.data_lev_up[this.lev + 1];
let cfg = game.configs.holy_eqm_lottery_data.data_pro_show[this.lev];
let nfg = game.configs.holy_eqm_lottery_data.data_pro_show[this.lev + 1];
let rates = [];
for (let i in cfg ) {
let rate = cfg[i];
rates.push( rate );
}
let nrates = [];
// if( nfg ){
// }
for (let i in nfg ) {
let rate = nfg[i];
nrates.push( rate );
}
nx.gui.gocChildren( this.nodRate,"", rates.length );
let chd = this.nodRate.children;
for (let i = 0; i < chd.length; i++) {
let nod = chd[i];
let rate = rates[i];
if( rate ){
nx.gui.setString( nod, "name", rate.name );
nx.gui.setString( nod, "rate", rate.pro + "%" );
nx.gui.setString( nod, "next", nrates[i] ? nrates[i].pro + "%" : rate.pro + "%" );
}
}
nx.gui.setString( this.nodNowLevel, "", nx.text.format( "StatueNowLv", this.lev ) );
nx.gui.setString( this.nodNextLevel, "", nx.dt.arrEmpty( nrates ) ? nx.text.getKey( "tip_heroMaxed" ) : nx.text.format( "NextLevel", this.lev + 1 ) );
let desc = nx.gui.find( this.nodMat, "desc" );
nx.gui.setString( desc, "desc", ncfg ? nx.text.format( "StatueUpDesc", ncfg.open_cond, _params.all_count, ncfg.open_cond ) : "" );
this.canUpLev = ncfg && ncfg.open_cond <= _params.all_count;
let str = !ncfg ? "" : ncfg.open_cond <= _params.all_count ? nx.text.getKey( "elfin_hatch_unlock_10" ) : nx.text.getKey( "elfin_hatch_unlock_9" );
nx.gui.setString( desc, "status", str );
let BC = BackPackController.getInstance();
let nodMat = nx.gui.find( this.nodMat, "mat" );
let chdMat = nodMat.children;
this.mat = [];
for (let j = 0; j < chdMat.length; j++) {
let nod = chdMat[j];
let mat = ncfg ? ncfg.items[j] : [];
if( nx.dt.arrEmpty( mat ) ){
nx.gui.setActive( nod, "", false );
continue;
}
let enough = true;
let have = BC.getModel().getItemNumByBid( mat[0] );
if( have < mat[1] ){
this.mat.push( mat[0] );
enough = false;
}
nx.bridge.setIconS( nod, "icon", mat[0] );
nx.gui.setString( nod, "count", nx.dt.shortCount( have ) + "/" + mat[1] );
nx.gui.setColor( nod, "count", !enough ? cc.Color.RED : cc.Color.WHITE );
nx.gui.setActive( nod, "", true );
}
nx.gui.setActive( this.nodMat, "op", ncfg );
nx.gui.setActive( this.nodMat, "max", !ncfg );
},
onTouchUpLev: function(){
let pray = PrayMod.getInstance();
if( nx.dt.arrNEmpty( this.mat ) || !this.canUpLev ){
nx.tbox( "lab_guild_request_item_tip8" );
return;
}
pray.sender25233( this.group_id );
},
// 重载:关闭前
onPreClosed: function() {
},
});