Files

128 lines
3.9 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
var BattleController = require("battle_controller");
var BattleEvent = require("battle_event");
const BridgeWindow = require("bridge.window");
const ItemLay = require( "cmp.common.itemlayout" );
cc.Class({
extends: BridgeWindow,
properties: {
list_panel:{
default:null,
type:ItemLay
},
detail_txt:{
default:null,
type:cc.RichText
}
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.ctrl = BattleController.getInstance();
this.model = this.ctrl.getModel();
},
start () {
},
// 重载:关闭前
onPreClosed: function() {
this.list_panel.rebuild([]);
},
onOpenConfigs(params){
this.form_id_list = params.form_id || [];
this.form_pos_info = {}
for(let k=0;k<this.form_id_list.length;++k){
let form_id = this.form_id_list[k]
let form_cfg = game.configs.combat_halo_data.data_halo[form_id]
if(form_cfg){
for(let i=0;i<form_cfg.pos_info.length;++i){
let v = form_cfg.pos_info[i]
let camp_type = v[0]
let camp_num = v[1]
if(!this.form_pos_info[camp_type]){
this.form_pos_info[camp_type] = camp_num
}else{
this.form_pos_info[camp_type] = this.form_pos_info[camp_type] + camp_num
}
}
}
}
this.detail_txt.string = game.configs.combat_halo_data.data_const.txt_data.val;
this.refreshCampList();
},
refreshCampList( ){
var self = this;
let camp_show_config = game.configs.combat_halo_data.data_halo_show;
if (camp_show_config){
let camp_data = [];
for(let k in camp_show_config){
let v = camp_show_config[k];
let data = nx.dt.objClone(v);
let show_cfg = {}
show_cfg.id = k
show_cfg.is_activate = false
for(let j in data){
let cfg = data[j]
cfg.is_activate = this.checkIsActivateCamp(cfg.pos_info)
if(cfg.is_activate){
show_cfg.is_activate = true
}
if(!show_cfg.name){
show_cfg.name = cfg.name
}
if(!show_cfg.icon){
show_cfg.icon = cfg.icon
}
}
show_cfg.attr_data = data
camp_data.push(show_cfg)
}
let SortFunc = function( objA, objB){
if (objA.is_activate && !objB.is_activate){
return -1;
}else if(!objA.is_activate && objB.is_activate){
return 1;
}else{
return objA.id - objB.id;
}
}
camp_data.sort(SortFunc);
for(let i=0;i<camp_data.length;++i){
camp_data[i].index = i
}
self.list_panel.rebuild(camp_data);
}
},
checkIsActivateCamp(pos_info){
let is_activate = false
if(pos_info){
is_activate = true
for(let i=0;i<pos_info.length;++i){
let v = pos_info[i]
let camp_type = v[0]
let camp_num = v[1]
let have_num = 0
for(let _type in this.form_pos_info){
let num = this.form_pos_info[_type]
if(_type == camp_type){
have_num = num
break
}
}
if(camp_num > have_num){
is_activate = false
break
}
}
}
return is_activate
},
// update (dt) {},
});