Files
fc/dev/project/assets/Scripts/mod/partner/cmps/bag/cmp.partner.bag.volume.js
T

73 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 伙伴背包容量
*
******************************************************************/
const BridgeComponent = require("bridge.component");
const HeroEvent = require("hero_event");
const HeroController = require("hero_controller");
cc.Class({
extends: BridgeComponent,
properties: {},
// 载入
onLoad: function () {
this._super();
this.bindGEvent(
HeroEvent.Buy_Hero_Max_Count_Event,
this.onFreshVolume.bind(this)
);
this.bindGEvent(
HeroEvent.Del_Hero_Event,
this.onFreshVolume.bind(this)
);
this.bindGEvent(HeroEvent.Hero_Data_Add, this.onFreshVolume.bind(this));
this.onFreshVolume();
},
// 关闭
onDestroy: function () {
this._super();
},
// 容量刷新
onFreshVolume: function () {
let HM = HeroController.getInstance().getModel();
let info = HM.getHeroMaxCount();
nx.gui.setString(this, "cur", info.have_coutn);
nx.gui.setString(this, "max", info.max_count);
let DATA = game.configs.partner_data.data_partner_buy;
let num = HM.getHeroBuyNum();
let cfg = DATA[num + 1];
nx.gui.setActive(this, "add", nx.dt.objNEmpty(cfg));
},
// 点击扩容
onTouchBuy: function () {
let HC = HeroController.getInstance();
let HM = HC.getModel();
let DATA = game.configs.partner_data.data_partner_buy;
let num = HM.getHeroBuyNum();
let cfg = DATA[num + 1];
if (nx.dt.objEmpty(cfg)) {
return;
}
let item_id = cfg.expend[0][0] || 3;
let count = cfg.expend[0][1];
let str = nx.text.format("msg_addBagNum", count, item_id, cfg.add_num);
nx.mbox(str, ["no", "yes"], (_key, _box) => {
_box.close();
if (_key == "yes") {
HC.sender11009();
}
});
},
});