148 lines
4.1 KiB
JavaScript
148 lines
4.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '1759fpVDrlDLquQPr4mvdQo', 'cmp.adventure.weeklyhero');
|
||
|
|
// Scripts/mod/pve/adventure/cmp/cmp.adventure.weeklyhero.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var ADVCT = require("adventure_controller");
|
||
|
|
var NxExpand = require("nx.fx.sv.expand");
|
||
|
|
var NxTogs = require("nx.fx.togs");
|
||
|
|
var 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: function 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: function start() {},
|
||
|
|
onOpenConfigs: function onOpenConfigs(params) {
|
||
|
|
this.onTogCamp(0);
|
||
|
|
},
|
||
|
|
onPreClosed: function onPreClosed() {
|
||
|
|
this.heros.rebuild([]);
|
||
|
|
},
|
||
|
|
onTogCamp: function onTogCamp(_index) {
|
||
|
|
var list = HeroController.getInstance().getModel().getRestHeroListByCamp(_index || 0);
|
||
|
|
list.sort(Utils.tableUpperSorter(["star", "power", "lev", "flag"]));
|
||
|
|
var High_star_list = [];
|
||
|
|
for (var 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: function onFocusHero(_item) {
|
||
|
|
if (!_item) return;
|
||
|
|
var hero = this.form_heros[_item.index];
|
||
|
|
if (hero) {
|
||
|
|
//已上陣,需要取消
|
||
|
|
this.heros.removeFocus(_item.index);
|
||
|
|
this.in_form--;
|
||
|
|
for (var 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; //上阵
|
||
|
|
var order = this.in_form;
|
||
|
|
for (var _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: function refreshFormHeros() {
|
||
|
|
for (var i = 0; i < 3; i++) {
|
||
|
|
var key = this.select_heros[i];
|
||
|
|
var hero_data = this.form_heros[key];
|
||
|
|
var ndForm = this.forms[i];
|
||
|
|
if (hero_data) {
|
||
|
|
nx.gui.setActive(ndForm, "hero", true);
|
||
|
|
nx.gui.setActive(ndForm, "add", false);
|
||
|
|
var ndHero = nx.gui.find(ndForm, "hero");
|
||
|
|
var cmp = nx.gui.getComponent(ndForm, "hero/item", "cmp.adventure.partner");
|
||
|
|
if (cmp) {
|
||
|
|
cmp.rebind(i, hero_data, "");
|
||
|
|
} else {
|
||
|
|
var 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: function clickSendForm() {
|
||
|
|
if (this.in_form > 0 && this.in_form <= 3) {
|
||
|
|
var list = [];
|
||
|
|
for (var i in this.form_heros) {
|
||
|
|
var data = this.form_heros[i];
|
||
|
|
list.push({
|
||
|
|
id: data.partner_id
|
||
|
|
});
|
||
|
|
}
|
||
|
|
var model_type = this.ctrl.getPlayModel();
|
||
|
|
this.ctrl.send29505(model_type, list);
|
||
|
|
this.close();
|
||
|
|
} else {
|
||
|
|
nx.tbox("arenateam_hall_tap_18");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//下阵英雄
|
||
|
|
clickDownForm: function clickDownForm(index) {
|
||
|
|
var order = this.select_heros[index];
|
||
|
|
var 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) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|