/**** * 合成面板 */ const ItemBase = require("cmp.item.base"); const BridgeWindow = require("bridge.window"); const SliderProgress = require("cmp.slider.prog.selector"); const BackPackController = require("backpack_controller"); const ElfinController = require( "elfin_controller" ); cc.Class({ extends: BridgeWindow, properties: { cmpItem: { default: null, type: ItemBase, }, cmpItem1: { default: null, type: ItemBase, }, cmpCounter: { default: null, type: SliderProgress, }, nodMat: { default: null, type: cc.Node, }, nodResult: { default: null, type: cc.Node, }, }, // 重载:参数打开 onOpenConfigs: function (_params) { // this.item = _params[0]; this.item = _params ; // if (!this.item || !this.config) { // nx.error("[Merge]合成失败,参数无效!"); // return; // } // 重建 this.rebuild(); }, // 重建 rebuild: function () { // 道具信息 this.cmpItem.setData(this.item); // // 数量范围&&默认 let Bag = BackPackController.getInstance().getModel(); let count = Bag.getPackItemNumByBid( 1, this.item ); let needCount = game.configs.sprite_data.data_const.liaoji_materials.val[1]; let itemMerge = game.configs.sprite_data.data_const.liaoji_target.val[0]; let cfg = game.configs.sprite_data.data_elfin_com[this.item]; nx.bridge.setIcon( this.nodMat, "mat1/icon", cfg.expend[1][0] ); this.price = cfg.expend[1][1]; nx.gui.setString( this.nodMat, "mat1/txt", ( this.price * count ) ); this.cmpItem1.setData( itemMerge ); let canMergeCount = Math.floor(parseInt(count / needCount)); this.canMerge = count >= needCount ; if (!this.canMerge) { this.cmpCounter.build(0, 0, 0, 0); } else { // 设置滚动条 this.cmpCounter.build(1, canMergeCount, canMergeCount, ( _count ) => { this.changeCount(_count); }); } // this.changeCount( count ); // this.cmpItem.setCount(0); }, // 数量改变 changeCount: function (_count) { nx.gui.setActive( this.nodMat, "", _count > 0 ); if (this.cur == _count || !nx.dt.numPositive(_count, false)) { return; } nx.gui.setString( this.nodMat, "mat1/txt", ( this.price * _count ) ); this.cur = _count; }, // 点击合成按钮 onTouchSell: function () { if (!this.canMerge) { nx.tbox("insufficent amount!"); this.cmpCounter.build(0, 0, 0, 0); return; } let EC = ElfinController.getInstance(); EC.sender26508(this.item, this.cur, 0); }, });