157 lines
4.3 KiB
JavaScript
157 lines
4.3 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const ADVCT = require("adventure_controller");
|
||
|
|
const NxExpand = require("nx.fx.sv.expand");
|
||
|
|
const NxTogs = require("nx.fx.togs");
|
||
|
|
const HeroController = require("hero_controller");
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
heros:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
camps:{
|
||
|
|
default:null,
|
||
|
|
type:NxTogs
|
||
|
|
},
|
||
|
|
fabHero:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
forms:{
|
||
|
|
default:[],
|
||
|
|
type:[cc.Node]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad () {
|
||
|
|
this.ctrl = ADVCT.getInstance();
|
||
|
|
this.form_heros = {};//已选中的英雄
|
||
|
|
this.in_form = 0;
|
||
|
|
this.select_heros = {};
|
||
|
|
this.camps.posTog = this.onTogCamp.bind(this);
|
||
|
|
this.camps.togTo(0);
|
||
|
|
},
|
||
|
|
|
||
|
|
start () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs(params) {
|
||
|
|
this.onTogCamp(0);
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed() {
|
||
|
|
this.heros.rebuild([]);
|
||
|
|
},
|
||
|
|
|
||
|
|
onTogCamp(_index){
|
||
|
|
let list = HeroController.getInstance().getModel().getRestHeroListByCamp( _index || 0 );
|
||
|
|
list.sort( Utils.tableUpperSorter( [ "star", "power", "lev", "flag" ] ) )
|
||
|
|
let High_star_list = [];
|
||
|
|
for(let i in list){
|
||
|
|
if(list[i].init_star == 5){
|
||
|
|
list[i].hp_per = null;
|
||
|
|
list[i].now_hp = null;
|
||
|
|
High_star_list.push(list[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.heros.rebuild(High_star_list);
|
||
|
|
},
|
||
|
|
|
||
|
|
onFocusHero(_item){
|
||
|
|
if(!_item)return;
|
||
|
|
|
||
|
|
let hero = this.form_heros[_item.index];
|
||
|
|
if(hero){//已上陣,需要取消
|
||
|
|
this.heros.removeFocus(_item.index);
|
||
|
|
this.in_form--;
|
||
|
|
for(let i in this.select_heros){
|
||
|
|
if(this.select_heros[i] == _item.index){
|
||
|
|
this.select_heros[i] = -1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
delete this.form_heros[_item.index];
|
||
|
|
}else{
|
||
|
|
if(this.in_form >= 3){
|
||
|
|
return nx.tbox("tip_fullPositions");
|
||
|
|
}
|
||
|
|
this.heros.addFocus(_item.index);
|
||
|
|
this.form_heros[_item.index] = _item.mdata;//上阵
|
||
|
|
let order = this.in_form;
|
||
|
|
for(let i in this.select_heros){
|
||
|
|
if(this.select_heros[i] == -1){
|
||
|
|
order = i;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.select_heros[order] = _item.index;
|
||
|
|
this.in_form++;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.refreshFormHeros();
|
||
|
|
},
|
||
|
|
|
||
|
|
refreshFormHeros(){
|
||
|
|
for(let i=0;i<3;i++){
|
||
|
|
let key = this.select_heros[i];
|
||
|
|
let hero_data = this.form_heros[key];
|
||
|
|
let ndForm = this.forms[i];
|
||
|
|
if(hero_data){
|
||
|
|
nx.gui.setActive(ndForm,"hero",true);
|
||
|
|
nx.gui.setActive(ndForm,"add",false);
|
||
|
|
let ndHero = nx.gui.find(ndForm,"hero");
|
||
|
|
let cmp = nx.gui.getComponent(ndForm,"hero/item","cmp.adventure.partner");
|
||
|
|
if(cmp){
|
||
|
|
cmp.rebind(i,hero_data,"");
|
||
|
|
}else{
|
||
|
|
let pre = cc.instantiate(this.fabHero);
|
||
|
|
pre.parent = ndHero;
|
||
|
|
cmp = nx.gui.getComponent(pre,"","cmp.adventure.partner");
|
||
|
|
cmp.rebind(i,hero_data,"");
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
nx.gui.setActive(ndForm,"hero",false);
|
||
|
|
nx.gui.setActive(ndForm,"add",true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//上陣
|
||
|
|
clickSendForm(){
|
||
|
|
if(this.in_form>0 && this.in_form<= 3){
|
||
|
|
let list = [];
|
||
|
|
for(let i in this.form_heros){
|
||
|
|
let data = this.form_heros[i];
|
||
|
|
list.push({id:data.partner_id});
|
||
|
|
}
|
||
|
|
let model_type = this.ctrl.getPlayModel();
|
||
|
|
this.ctrl.send29505(model_type,list);
|
||
|
|
this.close();
|
||
|
|
}else{
|
||
|
|
nx.tbox("arenateam_hall_tap_18");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//下阵英雄
|
||
|
|
clickDownForm(index){
|
||
|
|
let order = this.select_heros[index];
|
||
|
|
let hero = this.form_heros[order];
|
||
|
|
if(hero){//已上陣,需要取消
|
||
|
|
this.heros.removeFocus(order);
|
||
|
|
this.in_form--;
|
||
|
|
this.select_heros[index] = -1;
|
||
|
|
delete this.form_heros[order];
|
||
|
|
|
||
|
|
this.refreshFormHeros();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// update (dt) {},
|
||
|
|
});
|