102 lines
2.8 KiB
JavaScript
102 lines
2.8 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'cc618iMzClLv7WdGDyFhfJJ', 'cmp.wing.egg.merge');
|
|
// Scripts/mod/partner/wings/cmp/cmp.wing.egg.merge.js
|
|
|
|
"use strict";
|
|
|
|
/****
|
|
* 合成面板
|
|
*/
|
|
var ItemBase = require("cmp.item.base");
|
|
var BridgeWindow = require("bridge.window");
|
|
var SliderProgress = require("cmp.slider.prog.selector");
|
|
var BackPackController = require("backpack_controller");
|
|
var 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 onOpenConfigs(_params) {
|
|
// this.item = _params[0];
|
|
this.item = _params;
|
|
// if (!this.item || !this.config) {
|
|
// nx.error("[Merge]合成失败,参数无效!");
|
|
// return;
|
|
// }
|
|
|
|
// 重建
|
|
this.rebuild();
|
|
},
|
|
// 重建
|
|
rebuild: function rebuild() {
|
|
var _this = this;
|
|
// 道具信息
|
|
this.cmpItem.setData(this.item);
|
|
|
|
// // 数量范围&&默认
|
|
var Bag = BackPackController.getInstance().getModel();
|
|
var count = Bag.getPackItemNumByBid(1, this.item);
|
|
var needCount = game.configs.sprite_data.data_const.liaoji_materials.val[1];
|
|
var itemMerge = game.configs.sprite_data.data_const.liaoji_target.val[0];
|
|
var 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);
|
|
var 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, function (_count) {
|
|
_this.changeCount(_count);
|
|
});
|
|
}
|
|
// this.changeCount( count );
|
|
// this.cmpItem.setCount(0);
|
|
},
|
|
|
|
// 数量改变
|
|
changeCount: function changeCount(_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 onTouchSell() {
|
|
if (!this.canMerge) {
|
|
nx.tbox("insufficent amount!");
|
|
this.cmpCounter.build(0, 0, 0, 0);
|
|
return;
|
|
}
|
|
var EC = ElfinController.getInstance();
|
|
EC.sender26508(this.item, this.cur, 0);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |