Files
fc/dev/project/library/imports/b7/b78fbd8e-9dbe-4983-8221-9206a4b21823.js
T
2026-05-24 10:21:26 +08:00

181 lines
5.2 KiB
JavaScript

"use strict";
cc._RF.push(module, 'b78fb2Onb5Jg4Ihkgakshgj', 'cmp.adventure.ui.top');
// Scripts/mod/pve/adventure/cmp/cmp.adventure.ui.top.js
"use strict";
var BridgeComp = require("bridge.component");
var ADVCT = require("adventure_controller");
var ADEVT = require("adventure_event");
var NxExpand = require("nx.fx.sv.expand");
var 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: function 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: function updateGoods(data) {
var list = [];
this.goods = [];
if (data) {
list = data.items_list; //新數據
}
this.goodsList.rebuild(list);
this.goods = list;
},
updateBuffs: function updateBuffs(data) {
var list = [];
this.buffs = [];
if (data) {
list = data.buff_list;
}
this.buffList.rebuild(list);
this.buffs = list;
//刷新人物身上的buff状态
var mType = ADVCT.getInstance().getPlayModel();
if (mType == 1) {
var buff_data = game.configs.adventure_endless_data.data_buff;
for (var i = 0; i < list.length; i++) {
var 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 {
var buff_data2 = game.configs.adventure_weekly_data.data_adventure_event;
for (var _i = 0; _i < list.length; _i++) {
var 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: function clickMoreGoods() {
ADVCT.getInstance().openMoreItemsWindow(2, this.goods);
},
clickMoreBuffs: function clickMoreBuffs() {
ADVCT.getInstance().openMoreItemsWindow(1, this.buffs);
},
updateHeros: function updateHeros(partners) {
var index = 0;
var is_form = false;
for (var i in partners) {
var hero = this.heros[index];
if (!hero) {
var pre = cc.instantiate(this.fabHero);
this.useHeros[index].parent.active = true;
pre.parent = this.useHeros[index];
var cmp = pre.getComponent("cmp.adventure.partner");
this.heros[index] = cmp;
hero = cmp;
}
var 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 (var _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: function start() {},
onDisable: function onDisable() {
this.unbindGEvents();
this.goodsList.rebuild([]);
this.buffList.rebuild([]);
},
onEnable: function onEnable() {
var list = ADVCT.getInstance().getAllFormPartners();
this.updateHeros(list);
},
onTogHero: function onTogHero(e, _index) {
var hero = this.heros[Number(_index)];
if (!hero) {
var tog = this.heroTogs[this.select_hero];
tog.isChecked = true;
return;
}
if (hero.mdata.now_hp <= 0) {
var _tog = this.heroTogs[this.select_hero];
_tog.isChecked = true;
return nx.tbox("AdvenDead");
}
if (!e) {
var _tog2 = this.heroTogs[Number(_index)];
_tog2.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: function clickAddPower() {
var cfg = game.configs.adventure_weekly_data.data_adventure_const.prize;
var buyLimit = game.configs.adventure_weekly_data.data_adventure_const.buy_condition.val;
var str = cc.js.formatStr(nx.text.getKey("AdvenBuyEnerg"), cfg.val[0], cfg.val[1], buyLimit[1], buyLimit[0]);
nx.mbox(str, ["cancel", "confirm"], function (_key, _box) {
_box.close();
if (_key == "confirm") {
ADVCT.getInstance().send29513();
}
});
} // update (dt) {},
});
cc._RF.pop();