192 lines
5.5 KiB
JavaScript
192 lines
5.5 KiB
JavaScript
|
|
const BridgeComp = require("bridge.component");
|
||
|
|
const ADVCT = require("adventure_controller");
|
||
|
|
const ADEVT = require("adventure_event");
|
||
|
|
const NxExpand = require("nx.fx.sv.expand");
|
||
|
|
const HeroVo = require("hero_vo");
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
extends: BridgeComp,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
useHeros:{
|
||
|
|
default:[],
|
||
|
|
type:[cc.Node]
|
||
|
|
},
|
||
|
|
fabHero:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
goodsList:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
buffList:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
heroTogs:{
|
||
|
|
default:[],
|
||
|
|
type:[cc.Toggle]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad () {
|
||
|
|
this._super();
|
||
|
|
this.select_hero = 0;
|
||
|
|
this.heros = {};
|
||
|
|
this.goods = [];
|
||
|
|
this.buffs = [];
|
||
|
|
this.bindGEvent(ADEVT.Update_Goods,this.updateGoods.bind(this));
|
||
|
|
this.bindGEvent(ADEVT.Update_Hero_Info,this.updateHeros.bind(this));
|
||
|
|
this.bindGEvent(ADEVT.Udpate_Buff_List,this.updateBuffs.bind(this));
|
||
|
|
},
|
||
|
|
|
||
|
|
updateGoods(data){
|
||
|
|
let list = [];
|
||
|
|
this.goods = [];
|
||
|
|
if(data){
|
||
|
|
list = data.items_list;//新數據
|
||
|
|
}
|
||
|
|
|
||
|
|
this.goodsList.rebuild(list);
|
||
|
|
this.goods = list;
|
||
|
|
},
|
||
|
|
|
||
|
|
updateBuffs(data){
|
||
|
|
let list = [];
|
||
|
|
this.buffs = [];
|
||
|
|
if(data){
|
||
|
|
list = data.buff_list;
|
||
|
|
}
|
||
|
|
this.buffList.rebuild(list);
|
||
|
|
this.buffs = list;
|
||
|
|
|
||
|
|
//刷新人物身上的buff状态
|
||
|
|
let mType = ADVCT.getInstance().getPlayModel();
|
||
|
|
if(mType == 1){
|
||
|
|
let buff_data = game.configs.adventure_endless_data.data_buff;
|
||
|
|
for(let i=0;i<list.length;i++){
|
||
|
|
let buff = list[i];
|
||
|
|
if(buff_data[buff.bid] && buff_data[buff.bid].effect == "E66002"){
|
||
|
|
gcore.GlobalEvent.fire(ADEVT.Update_Role_Good_Status,buff_data[buff.bid].effect);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
let buff_data2 = game.configs.adventure_weekly_data.data_adventure_event;
|
||
|
|
for(let i=0;i<list.length;i++){
|
||
|
|
let buff2 = list[i];
|
||
|
|
if(buff_data2[buff2.bid] && buff_data2[buff2.bid].effect == "E66002"){
|
||
|
|
gcore.GlobalEvent.fire(ADEVT.Update_Role_Good_Status,buff_data2[buff2.bid].effect);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//没有中毒就不播放特效
|
||
|
|
gcore.GlobalEvent.fire(ADEVT.Update_Role_Good_Status,"");
|
||
|
|
},
|
||
|
|
|
||
|
|
clickMoreGoods(){
|
||
|
|
ADVCT.getInstance().openMoreItemsWindow(2,this.goods);
|
||
|
|
},
|
||
|
|
|
||
|
|
clickMoreBuffs(){
|
||
|
|
ADVCT.getInstance().openMoreItemsWindow(1,this.buffs);
|
||
|
|
},
|
||
|
|
|
||
|
|
updateHeros(partners){
|
||
|
|
let index = 0;
|
||
|
|
let is_form = false;
|
||
|
|
for(let i in partners){
|
||
|
|
let hero = this.heros[index];
|
||
|
|
if(!hero){
|
||
|
|
let pre = cc.instantiate(this.fabHero);
|
||
|
|
this.useHeros[index].parent.active = true;
|
||
|
|
pre.parent = this.useHeros[index];
|
||
|
|
let cmp = pre.getComponent("cmp.adventure.partner");
|
||
|
|
this.heros[index] = cmp;
|
||
|
|
hero = cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
let hero_vo = new HeroVo();
|
||
|
|
hero_vo.updateHeroVo(partners[i]);
|
||
|
|
hero.rebind(index,hero_vo,"");
|
||
|
|
index++;
|
||
|
|
}
|
||
|
|
|
||
|
|
//死亡推移
|
||
|
|
if(this.heros[this.select_hero] && this.heros[this.select_hero].mdata.now_hp <= 0){
|
||
|
|
for(let hero in this.heros){
|
||
|
|
if(this.heros[hero].mdata.now_hp > 0){
|
||
|
|
is_form = true;
|
||
|
|
this.select_hero = hero;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(!is_form){
|
||
|
|
this.select_hero = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
this.onTogHero(null,this.select_hero);
|
||
|
|
},
|
||
|
|
|
||
|
|
start () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onDisable(){
|
||
|
|
this.unbindGEvents();
|
||
|
|
this.goodsList.rebuild([]);
|
||
|
|
this.buffList.rebuild([]);
|
||
|
|
},
|
||
|
|
|
||
|
|
onEnable(){
|
||
|
|
let list = ADVCT.getInstance().getAllFormPartners();
|
||
|
|
this.updateHeros(list);
|
||
|
|
},
|
||
|
|
|
||
|
|
onTogHero(e,_index){
|
||
|
|
let hero = this.heros[Number(_index)];
|
||
|
|
if(!hero){
|
||
|
|
let tog = this.heroTogs[this.select_hero];
|
||
|
|
tog.isChecked = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if(hero.mdata.now_hp <= 0){
|
||
|
|
let tog = this.heroTogs[this.select_hero];
|
||
|
|
tog.isChecked = true;
|
||
|
|
return nx.tbox("AdvenDead");
|
||
|
|
}
|
||
|
|
if(!e){
|
||
|
|
let tog = this.heroTogs[Number(_index)];
|
||
|
|
tog.isChecked = true;
|
||
|
|
}
|
||
|
|
if(e && Number(_index) == this.select_hero){//展示面板·
|
||
|
|
nx.bridge.createPanel("WndAdventureDetail",{bid:hero.mdata.bid});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.select_hero = Number(_index);
|
||
|
|
ADVCT.getInstance().setCurLeader(hero.mdata.bid);
|
||
|
|
ADVCT.getInstance().send29510(hero.mdata.bid);
|
||
|
|
gcore.GlobalEvent.fire(ADEVT.Update_Role_Model);
|
||
|
|
},
|
||
|
|
|
||
|
|
clickAddPower(){
|
||
|
|
let cfg = game.configs.adventure_weekly_data.data_adventure_const.prize;
|
||
|
|
let buyLimit = game.configs.adventure_weekly_data.data_adventure_const.buy_condition.val;
|
||
|
|
let str = cc.js.formatStr(nx.text.getKey("AdvenBuyEnerg"),cfg.val[0],cfg.val[1],buyLimit[1],buyLimit[0]);
|
||
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
||
|
|
_box.close();
|
||
|
|
if(_key == "confirm"){
|
||
|
|
ADVCT.getInstance().send29513();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
// update (dt) {},
|
||
|
|
});
|