/****************************************************************** * * 伙伴背包容量 * ******************************************************************/ 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(); } }); }, });