734 lines
25 KiB
JavaScript
734 lines
25 KiB
JavaScript
var MofahechengManager = class MofahechengManager extends egret.EventDispatcher {
|
||
constructor() {
|
||
super();
|
||
}
|
||
static getInstance() {
|
||
return (this._instance || (this._instance = new MofahechengManager()), this._instance);
|
||
}
|
||
sendNetJiagong() {
|
||
const t = this.curData.goods_id,
|
||
e = t.split(":"),
|
||
i = (e[0], int(e[1]));
|
||
Global.netProxy.sendRequest(
|
||
GameConfig.SERVER_PATH + "compose/do",
|
||
{
|
||
compose_id: this.curData.id,
|
||
count: i
|
||
},
|
||
this.onSendNetJiagong.bind(this)
|
||
);
|
||
}
|
||
async onSendNetJiagong(response) {
|
||
if (0 != response.status) {
|
||
TipsUtils.showTipsDownToUp(GameConfig.ServerCode[response.status]);
|
||
return;
|
||
}
|
||
|
||
const goodsInfo = this.curData.goods_id;
|
||
const goodsParts = goodsInfo.split(":");
|
||
const itemId = goodsParts[0];
|
||
const itemCount = int(goodsParts[1]);
|
||
const itemName = Global.gameProxy.getItemConfig(itemId).name;
|
||
Global.playerProxy.updateWareHouseItem(
|
||
{
|
||
item_id: itemId
|
||
},
|
||
itemCount
|
||
);
|
||
TipsUtils.showTipsDownToUp("获得[" + itemName + "]X" + itemCount);
|
||
const experience = int(this.curData.experience);
|
||
Global.playerProxy.playerData.exp += experience;
|
||
await egret.setTimeout(
|
||
function () {
|
||
TipsUtils.showTipsDownToUp("获得[经验]X" + this.curData.experience);
|
||
},
|
||
this,
|
||
2e3
|
||
);
|
||
|
||
for (const fieldName in this.curData)
|
||
if (
|
||
"fruit_id1" == fieldName ||
|
||
"fruit_id2" == fieldName ||
|
||
"fruit_id3" == fieldName ||
|
||
"fruit_id4" == fieldName ||
|
||
"fruit_id5" == fieldName ||
|
||
"fruit_id6" == fieldName
|
||
) {
|
||
const materialInfo = this.curData[fieldName];
|
||
const materialParts = materialInfo.split(":");
|
||
const materialId = materialParts[0];
|
||
const materialCount = int(materialParts[1]);
|
||
"105001" == materialId
|
||
? (Global.playerProxy.playerData.gem -= materialCount)
|
||
: "105002" == materialId
|
||
? (Global.playerProxy.playerData.gold -= materialCount)
|
||
: "201000" == materialId
|
||
? (Global.playerProxy.playerData.stone -= materialCount)
|
||
: "201001" == materialId
|
||
? (Global.playerProxy.playerData.steel -= materialCount)
|
||
: Global.playerProxy.sellWareHouseItem(
|
||
{
|
||
id: materialId
|
||
},
|
||
materialCount
|
||
);
|
||
}
|
||
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
|
||
game.EventManager.instance.dispatch(SysNotify.MOFAHECHENG_UPDATA);
|
||
}
|
||
};
|
||
__reflect(MofahechengManager.prototype, "MofahechengManager");
|
||
var game;
|
||
!(function (game) {
|
||
const MofahechengMidter = class MofahechengMidter extends BaseMediator {
|
||
constructor() {
|
||
super("MofahechengMidter");
|
||
this.groupName = "mofahecheng_json";
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_MOFAHECHENG, PanelNotify.CLOSE_MOFAHECHENG];
|
||
}
|
||
onRegister() {
|
||
super.onRegister();
|
||
}
|
||
showViewComponent(t = 7) {
|
||
((this.viewComponent = new MofahechengPanel()), this.showUI(this.viewComponent, !0, 0, 0, t));
|
||
}
|
||
handleNotification(t) {
|
||
t.getBody();
|
||
switch (t.getName()) {
|
||
case PanelNotify.OPEN_MOFAHECHENG:
|
||
this.showViewComponent(10);
|
||
break;
|
||
case PanelNotify.CLOSE_MOFAHECHENG:
|
||
this.closeViewComponent(10);
|
||
}
|
||
}
|
||
static NAME = "MofahechengMidter";
|
||
};
|
||
((game.MofahechengMidter = MofahechengMidter), __reflect(MofahechengMidter.prototype, "game.MofahechengMidter"));
|
||
})(game || (game = {}));
|
||
var MofahechengPanel = class MofahechengPanel extends game.BasePanel {
|
||
constructor() {
|
||
super();
|
||
this.unitarr = [];
|
||
this.radioArr = [];
|
||
this.skinName = MofahechengPanelSkin;
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
(this.commonPanel.closeBtn.y = 600),
|
||
(this.commonPanel.closeBtn.label = "离开"),
|
||
this.init());
|
||
}
|
||
init() {
|
||
((this.unitarr.length = 0),
|
||
this.unitarr.push(this.unit0),
|
||
this.unitarr.push(this.unit1),
|
||
this.unitarr.push(this.unit2),
|
||
this.unitarr.push(this.unit3),
|
||
this.unitarr.push(this.unit4),
|
||
(this.radioArr.length = 0),
|
||
this.likaiBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTab, this),
|
||
(this.radioGroup = new eui.RadioButtonGroup()),
|
||
(this.radio0.group = this.radioGroup),
|
||
this.radioArr.push(this.radio0),
|
||
(this.radio1.group = this.radioGroup),
|
||
this.radioArr.push(this.radio1),
|
||
(this.radio2.group = this.radioGroup),
|
||
this.radioArr.push(this.radio2),
|
||
(this.radio3.group = this.radioGroup),
|
||
this.radioArr.push(this.radio3),
|
||
(this.radio4.group = this.radioGroup),
|
||
this.radioArr.push(this.radio4),
|
||
this.radioGroup.addEventListener(egret.Event.CHANGE, this.onRadiochange, this),
|
||
(this.radio0.selected = !0),
|
||
game.UIUtils.addShortTouch(this.zhizuoButton, this.onZhizuo, null),
|
||
game.EventManager.instance.addEvent(SysNotify.MOFAHECHENG_UPDATA, this.sysMofahechengUpdata, this),
|
||
this.initData());
|
||
}
|
||
sysMofahechengUpdata() {
|
||
this.updataAll();
|
||
}
|
||
uninit() {
|
||
(this.likaiBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTab, this),
|
||
this.radioGroup.removeEventListener(egret.Event.CHANGE, this.onRadiochange, this),
|
||
(this.radioGroup = null));
|
||
}
|
||
createChildren() {
|
||
(super.createChildren(),
|
||
(this.isFullScreen = !0),
|
||
(this.isVisibleAnimate = !0),
|
||
this.commonPanel.setPanelWidth(640),
|
||
this.commonPanel.setPanelHeight(800),
|
||
this.commonPanel.setTitle("mofahecheng_json.mofahecheng_title_png"));
|
||
}
|
||
initData() {
|
||
for (let t = 0, e = Global.gameProxy.getCurhechengArrforLV(t), i = 0; i < e.length; i++) {
|
||
const n = e[i],
|
||
a = this.radioArr[i];
|
||
a.value = n;
|
||
const o = n.goods_id,
|
||
r = o.split(":"),
|
||
s = Global.gameProxy.getItemImageId(r[0]);
|
||
((a.icons.source = s + "_png"), 0 == i && (MofahechengManager.getInstance().curData = e[i]));
|
||
}
|
||
this.updataAll();
|
||
}
|
||
updataAll() {
|
||
const t = MofahechengManager.getInstance().curData;
|
||
var e = t.fruit_id1;
|
||
var i = e.split(":");
|
||
const n = i[0];
|
||
const a = Global.playerProxy.getHasItemByItemId(n);
|
||
const o = a ? a.number : 0;
|
||
let r = 1;
|
||
for (const s in t)
|
||
if (s == "fruit_id" + r && 6 > r) {
|
||
const e = t[s],
|
||
i = e.split(":"),
|
||
l = Global.gameProxy.getItemImageId(i[0]);
|
||
this.unitarr[r - 1].icons.source = l + "_png";
|
||
const h = int(i[1]);
|
||
if (o >= r * h)
|
||
((this.unitarr[r - 1].numLabel.text = h + "/" + h), (this.unitarr[r - 1].numLabel.textColor = 16777215));
|
||
else {
|
||
let c = o - h * r;
|
||
((c = c > -h ? h + c : 0),
|
||
(this.unitarr[r - 1].numLabel.text = c + "/" + h),
|
||
(this.unitarr[r - 1].numLabel.textColor = 16188462));
|
||
}
|
||
const p = new SimpleItemData(Global.gameProxy.getItemConfig(i[0]));
|
||
((this.unitarr[r - 1].itemData = p), r++);
|
||
}
|
||
const d = t.fruit_id6,
|
||
u = d.split(":");
|
||
this.goldLabel.text = u[1];
|
||
}
|
||
onRadiochange(t) {
|
||
const e = this.radioGroup.selectedValue;
|
||
((MofahechengManager.getInstance().curData = e), this.updataAll());
|
||
}
|
||
onTab() {
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_MOFAHECHENG);
|
||
}
|
||
onZhizuo() {
|
||
MofahechengManager.getInstance().sendNetJiagong();
|
||
}
|
||
};
|
||
__reflect(MofahechengPanel.prototype, "MofahechengPanel");
|
||
var MofahechengRadioButton = class MofahechengRadioButton extends eui.RadioButton {
|
||
constructor() {
|
||
super();
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
game.UIUtils.addShortTouch(this.icons, this.onShortTouchBegan.bind(this), this.onShortTouchEnd.bind(this)));
|
||
}
|
||
onShortTouchBegan() {
|
||
this.itemData &&
|
||
game.ItemTip.show(this.itemData, this.icons.localToGlobal(this.icons.width / 2, this.icons.height / 2));
|
||
}
|
||
onShortTouchEnd() {
|
||
game.ItemTip.hide();
|
||
}
|
||
};
|
||
__reflect(MofahechengRadioButton.prototype, "MofahechengRadioButton");
|
||
var MofahechengUnit = class MofahechengUnit extends eui.Component {
|
||
constructor() {
|
||
super();
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
game.UIUtils.addShortTouch(this.icons, this.onShortTouchBegan.bind(this), this.onShortTouchEnd.bind(this)));
|
||
}
|
||
onShortTouchBegan() {
|
||
this.itemData &&
|
||
game.ItemTip.show(this.itemData, this.icons.localToGlobal(this.icons.width / 2, this.icons.height / 2));
|
||
}
|
||
onShortTouchEnd() {
|
||
game.ItemTip.hide();
|
||
}
|
||
};
|
||
__reflect(MofahechengUnit.prototype, "MofahechengUnit");
|
||
var MofajaigongItemRender = class MofajaigongItemRender extends eui.RadioButton {
|
||
constructor() {
|
||
super();
|
||
this.index = 0;
|
||
this.skinName = MofajaigongItemRenderSkin;
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(), (this.iconImg.touchEnabled = !0));
|
||
}
|
||
};
|
||
__reflect(MofajaigongItemRender.prototype, "MofajaigongItemRender");
|
||
var MofajaigongPanel2 = class MofajaigongPanel2 extends eui.Component {
|
||
constructor() {
|
||
super();
|
||
this.unitarr = [];
|
||
this.skinName = Mofajiagong2PanelSkin;
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
game.EventManager.instance.addEvent(SysNotify.MOFAJIAGONG_UPDATA, this.sysMofaUpdata, this),
|
||
game.UIUtils.addShortTouch(this.shengjiButton, this.onShengjiButtonBegin, this.onShengjiButtonEnd),
|
||
this.updata());
|
||
}
|
||
sysMofaUpdata() {
|
||
this.updata();
|
||
}
|
||
onShengjiButtonBegin() {
|
||
MofaManager.getInstance().sendNetupLevel();
|
||
}
|
||
onShengjiButtonEnd() {}
|
||
updata() {
|
||
((this.unitarr.length = 0),
|
||
this.unitarr.push(this.unit0),
|
||
this.unitarr.push(this.unit1),
|
||
this.unitarr.push(this.unit2),
|
||
this.unitarr.push(this.unit3),
|
||
this.unitarr.push(this.unit4));
|
||
const t = Global.playerProxy.playerData.factory_level;
|
||
const e = Global.playerProxy.playerData.factory_exp;
|
||
let i = Global.gameProxy.getFactoryConfigForID(t + 1);
|
||
if ((i || (i = Global.gameProxy.getFactoryConfigForID(t)), i)) {
|
||
let n = 1;
|
||
for (const a in i)
|
||
if (a == "fruit_id" + n) {
|
||
const o = i[a];
|
||
let r = o.split(":");
|
||
1 == r.length && ((r.length = 0), (r = o.split(":")));
|
||
const s = Global.gameProxy.getItemImageId(r[0]);
|
||
(this.unitarr[n - 1].setIcon(s + "_png"), this.unitarr[n - 1].setNum(int(r[1])));
|
||
const l = new SimpleItemData(Global.gameProxy.getItemConfig(r[0]));
|
||
((this.unitarr[n - 1].itemData = l), n++);
|
||
}
|
||
const h = e,
|
||
c = i.experience;
|
||
(this.prossbar.setPross(h, c),
|
||
(this.goldLabel.text = i.gold),
|
||
0 == t
|
||
? (this.imgbgfang.source = "mofajiagong_tubiao_png")
|
||
: 3 == t
|
||
? (this.imgbgfang.source = "mofajiagongbtn3_png")
|
||
: (this.imgbgfang.source = "mofajiagong_btn" + t + "_png"),
|
||
(this.iconImg.source = "3002_png"));
|
||
}
|
||
}
|
||
};
|
||
__reflect(MofajaigongPanel2.prototype, "MofajaigongPanel2", ["eui.UIComponent", "egret.DisplayObject"]);
|
||
var MofajaigongUnitItem = class MofajaigongUnitItem extends eui.ItemRenderer {
|
||
constructor() {
|
||
super();
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
game.UIUtils.addShortTouch(this.iconImg, this.onShortTouchBegan.bind(this), this.onShortTouchEnd.bind(this)));
|
||
}
|
||
onShortTouchBegan() {
|
||
this.itemData &&
|
||
game.ItemTip.show(this.itemData, this.iconImg.localToGlobal(this.iconImg.width / 2, this.iconImg.height / 2));
|
||
}
|
||
onShortTouchEnd() {
|
||
game.ItemTip.hide();
|
||
}
|
||
setIcon(t) {
|
||
("" == t ? (this.iconImg.visible = !1) : (this.iconImg.visible = !0), (this.iconImg.source = t));
|
||
}
|
||
setNum(t) {
|
||
(0 == t ? (this.numlabel.visible = !1) : (this.numlabel.visible = !0), (this.numlabel.text = "X" + t));
|
||
}
|
||
dataChanged() {
|
||
super.dataChanged();
|
||
}
|
||
};
|
||
__reflect(MofajaigongUnitItem.prototype, "MofajaigongUnitItem");
|
||
var MOfajiagongChangeButton = class MOfajiagongChangeButton extends eui.RadioButton {
|
||
constructor() {
|
||
super();
|
||
}
|
||
};
|
||
__reflect(MOfajiagongChangeButton.prototype, "MOfajiagongChangeButton");
|
||
var game;
|
||
!(function (game) {
|
||
const MofajiagongMediter = class MofajiagongMediter extends BaseMediator {
|
||
constructor() {
|
||
super("MofajiagongMediter");
|
||
}
|
||
listNotificationInterests() {
|
||
return [PanelNotify.OPEN_MOFA, PanelNotify.CLOSE_MOFA];
|
||
}
|
||
onRegister() {
|
||
super.onRegister();
|
||
}
|
||
showViewComponent(e = 7) {
|
||
((this.viewComponent = new game.MofaJiaGongPanel()), this.showUI(this.viewComponent, !0, 0, 0, e));
|
||
}
|
||
handleNotification(t) {
|
||
t.getBody();
|
||
switch (t.getName()) {
|
||
case PanelNotify.OPEN_MOFA:
|
||
this.showViewComponent(10);
|
||
break;
|
||
case PanelNotify.CLOSE_MOFA:
|
||
this.closeViewComponent(10);
|
||
}
|
||
}
|
||
static NAME = "MofajiagongMediter";
|
||
};
|
||
((game.MofajiagongMediter = MofajiagongMediter), __reflect(MofajiagongMediter.prototype, "game.MofajiagongMediter"));
|
||
})(game || (game = {}));
|
||
var game;
|
||
!(function (game) {
|
||
const MofaJiaGongPanel = class MofaJiaGongPanel extends game.BasePanel {
|
||
constructor() {
|
||
super();
|
||
this.isFullScreen = !0;
|
||
this.isVisibleAnimate = !0;
|
||
this.skinName = MofajiagongPanelSkin;
|
||
}
|
||
onAdded() {
|
||
super.onAdded();
|
||
}
|
||
onRemoved() {
|
||
super.onRemoved();
|
||
}
|
||
createChildren() {
|
||
(super.createChildren(),
|
||
(this.isFullScreen = !0),
|
||
(this.isVisibleAnimate = !0),
|
||
this.commonPanel.setPanelWidth(640),
|
||
this.commonPanel.setPanelHeight(900),
|
||
this.commonPanel.setTitle("mofajiagong_title_png"));
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
(this.commonPanel.closeBtn.y = 900),
|
||
(this.commonPanel.closeBtn.label = "离开"),
|
||
(this.radioButtonGroup = new eui.RadioButtonGroup()),
|
||
(this.radioButton0.group = this.radioButtonGroup),
|
||
(this.radioButton0.value = 0),
|
||
(this.radioButton1.group = this.radioButtonGroup),
|
||
(this.radioButton1.value = 1),
|
||
(this.radioButton0.selected = !0),
|
||
(this.panel1.visible = !0),
|
||
(this.panel2.visible = !1),
|
||
this.radioButtonGroup.addEventListener(egret.Event.CHANGE, this.change, this));
|
||
}
|
||
change(t) {
|
||
0 == this.radioButtonGroup.selectedValue
|
||
? ((this.panel1.visible = !0), (this.panel2.visible = !1))
|
||
: ((this.panel2.visible = !0), (this.panel1.visible = !1));
|
||
}
|
||
btnCloseTouchEnded() {
|
||
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_MOFA);
|
||
}
|
||
};
|
||
((game.MofaJiaGongPanel = MofaJiaGongPanel), __reflect(MofaJiaGongPanel.prototype, "game.MofaJiaGongPanel"));
|
||
})(game || (game = {}));
|
||
var MofajiagongPanel1 = class MofajiagongPanel1 extends eui.Component {
|
||
constructor() {
|
||
super();
|
||
this.skinName = Mofajiagong1PanelSkin;
|
||
this.groups = new eui.Group();
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(),
|
||
(this.scrolls.viewport = this.groups),
|
||
(this.scrolls.scrollPolicyH = eui.ScrollPolicy.ON),
|
||
(this.scrolls.scrollPolicyV = eui.ScrollPolicy.OFF),
|
||
this.btnjian.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnJian, this),
|
||
this.btnjia.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnJia, this),
|
||
this.labelNum.addEventListener(egret.Event.CHANGE, this.onTextChange, this),
|
||
this.btnjiagong.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onJiagong, this),
|
||
game.EventManager.instance.addEvent(SysNotify.MOFAJIAGONG_UPDATA, this.sysMofaUpdata, this),
|
||
this.leftButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLeft, this),
|
||
this.rightButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRight, this),
|
||
this.init());
|
||
}
|
||
onTextChange(t) {
|
||
const e = RegUtils.isInteger(this.labelNum.text);
|
||
(e || (this.labelNum.text = "1"), (MofaManager.getInstance().curNum = int(this.labelNum.text)), this.updataAll());
|
||
}
|
||
onLeft(t) {
|
||
const e = this.gs.selection,
|
||
i = e.index;
|
||
if (i - 1 >= 0) {
|
||
const n = this.groups.getChildAt(i - 1);
|
||
((n.selected = !0), (MofaManager.getInstance().curFactoryData = n.value));
|
||
}
|
||
this.updataAll();
|
||
}
|
||
onRight(t) {
|
||
const e = this.gs.selection,
|
||
i = e.index;
|
||
if (i + 1 < this.groups.numChildren) {
|
||
const n = this.groups.getChildAt(i + 1);
|
||
((n.selected = !0), (MofaManager.getInstance().curFactoryData = n.value));
|
||
}
|
||
this.updataAll();
|
||
}
|
||
onJiagong() {
|
||
MofaManager.getInstance().sendNetJiagong();
|
||
}
|
||
sysMofaUpdata() {
|
||
this.updataAll();
|
||
}
|
||
init() {
|
||
const t = Global.gameProxy.getCurItemArrforFactoryLV(Global.playerProxy.playerData.factory_level);
|
||
this.updataRadioGroup(t);
|
||
}
|
||
updataAll() {
|
||
(this.updataDesGroup(), this.updataItem());
|
||
}
|
||
updataRadioGroup(t) {
|
||
((MofaManager.getInstance().curNum = 1),
|
||
this.groups.removeChildren(),
|
||
(this.labelNum.text = MofaManager.getInstance().curNum.toString()),
|
||
(this.gs = new eui.RadioButtonGroup()));
|
||
for (let e = 0; e < t.length; e++) {
|
||
const i = new MofajaigongItemRender(),
|
||
n = t[e].goods_id,
|
||
a = n.split(":"),
|
||
o = a[0],
|
||
r = (a[1], Global.gameProxy.getItemImageId(o));
|
||
((i.iconImg.source = r + "_png"), (i.numlabel.text = ""));
|
||
const s = new SimpleItemData(Global.gameProxy.getItemConfig(o));
|
||
((i.itemData = s),
|
||
this.groups.addChild(i),
|
||
(i.index = e),
|
||
(i.x = i.width * e),
|
||
(i.group = this.gs),
|
||
(i.value = t[e]),
|
||
0 == e && ((i.selected = !0), (MofaManager.getInstance().curFactoryData = t[e]), this.updataAll()));
|
||
}
|
||
((this.scrolls.viewport = this.groups), this.gs.addEventListener(egret.Event.CHANGE, this.onChange, this));
|
||
}
|
||
onChange(t) {
|
||
const e = this.gs.selectedValue;
|
||
((MofaManager.getInstance().curFactoryData = e), this.updataAll());
|
||
}
|
||
updataDesGroup() {
|
||
const t = MofaManager.getInstance().curFactoryData,
|
||
e = t.goods_id,
|
||
i = e.split(":"),
|
||
n = i[0],
|
||
a = Global.gameProxy.getItemConfig(n);
|
||
((this.labelLan.text = a.name), (this.DesLabel.text = a.desc));
|
||
const o = t.fruit_id4,
|
||
r = o.split(":"),
|
||
s = int(r[1]),
|
||
l = MofaManager.getInstance().curNum;
|
||
((this.labeljiagongNum.text = (s * l).toString()),
|
||
"105002" == r[0] ? (MofaManager.getInstance().type = 1) : (MofaManager.getInstance().type = 0),
|
||
(this.icons.source = Global.gameProxy.getItemImageId(r[0]) + "_png"),
|
||
(this.labelNum.text = MofaManager.getInstance().curNum.toString()));
|
||
}
|
||
updataItem() {
|
||
const t = MofaManager.getInstance().curFactoryData;
|
||
for (const e in t) {
|
||
if ("fruit_id1" == e) {
|
||
var i = t[e],
|
||
n = i.split(":");
|
||
this.unit0.setNum(int(n[1]));
|
||
var a = Global.gameProxy.getItemImageId(n[0]);
|
||
this.unit0.setIcon(a + "_png");
|
||
var o = new SimpleItemData(Global.gameProxy.getItemConfig(n[0]));
|
||
this.unit0.itemData = o;
|
||
}
|
||
if ("fruit_id2" == e) {
|
||
var i = t[e],
|
||
n = i.split(":");
|
||
this.unit1.setNum(int(n[1]));
|
||
var a = Global.gameProxy.getItemImageId(n[0]);
|
||
this.unit1.setIcon(a + "_png");
|
||
var o = new SimpleItemData(Global.gameProxy.getItemConfig(n[0]));
|
||
this.unit1.itemData = o;
|
||
}
|
||
if ("fruit_id3" == e) {
|
||
var i = t[e],
|
||
n = i.split(":");
|
||
this.unit2.setNum(int(n[1]));
|
||
var a = Global.gameProxy.getItemImageId(n[0]);
|
||
this.unit2.setIcon(a + "_png");
|
||
var o = new SimpleItemData(Global.gameProxy.getItemConfig(n[0]));
|
||
this.unit2.itemData = o;
|
||
}
|
||
}
|
||
const r = t.goods_id,
|
||
s = r.split(":"),
|
||
l = Global.gameProxy.getItemImageId(s[0]);
|
||
this.hechengIcon.source = l + "_png";
|
||
}
|
||
onBtnJian(t) {
|
||
const e = MofaManager.getInstance().curNum;
|
||
(e > 1 ? (MofaManager.getInstance().curNum -= 1) : (MofaManager.getInstance().curNum = 1), this.updataAll());
|
||
}
|
||
onBtnJia(t) {
|
||
const e = MofaManager.getInstance().curNum;
|
||
(99 > e ? (MofaManager.getInstance().curNum += 1) : (MofaManager.getInstance().curNum = 99), this.updataAll());
|
||
}
|
||
};
|
||
__reflect(MofajiagongPanel1.prototype, "MofajiagongPanel1");
|
||
var MofaManager = class MofaManager extends egret.EventDispatcher {
|
||
constructor() {
|
||
super();
|
||
this.curNum = 1;
|
||
this.type = 1;
|
||
}
|
||
static getInstance() {
|
||
return (this._insatance || (this._insatance = new MofaManager()), this._insatance);
|
||
}
|
||
sendNetJiagong() {
|
||
const t = this.curFactoryData.id;
|
||
Global.netProxy.sendRequest(
|
||
GameConfig.SERVER_PATH + "factory/do",
|
||
{
|
||
factory_id: t,
|
||
count: this.curNum
|
||
},
|
||
this.onSendNetJiagong.bind(this)
|
||
);
|
||
}
|
||
onSendNetJiagong(t) {
|
||
if (0 === t.status) {
|
||
const e = this.curFactoryData.goods_id,
|
||
i = e.split(":"),
|
||
n = i[0],
|
||
a = int(i[1]);
|
||
if ("201000" == n)
|
||
((Global.playerProxy.playerData.stone += this.curNum * a),
|
||
TipsUtils.showTipsDownToUp("获得[石材]X" + this.curNum * a));
|
||
else if ("201001" == n)
|
||
((Global.playerProxy.playerData.steel += this.curNum * a),
|
||
TipsUtils.showTipsDownToUp("获得[钢材]X" + this.curNum * a));
|
||
else {
|
||
Global.playerProxy.updateWareHouseItem(
|
||
{
|
||
item_id: n
|
||
},
|
||
this.curNum
|
||
);
|
||
const o = Global.gameProxy.getItemConfig(n).name;
|
||
TipsUtils.showTipsDownToUp("获得[" + o + "]X" + this.curNum * a);
|
||
}
|
||
const r = int(this.curFactoryData.experience);
|
||
Global.playerProxy.playerData.exp += r;
|
||
for (const s in this.curFactoryData)
|
||
if ("fruit_id1" == s || "fruit_id2" == s || "fruit_id3" == s || "fruit_id4" == s) {
|
||
const l = this.curFactoryData[s],
|
||
h = l.split(":"),
|
||
c = h[0],
|
||
p = int(h[1]);
|
||
"105001" == c
|
||
? (Global.playerProxy.playerData.gem -= p * this.curNum)
|
||
: "105002" == c
|
||
? (Global.playerProxy.playerData.gold -= p * this.curNum)
|
||
: "201000" == c
|
||
? (Global.playerProxy.playerData.stone -= p * this.curNum)
|
||
: "201001" == c
|
||
? (Global.playerProxy.playerData.steel -= p * this.curNum)
|
||
: Global.playerProxy.sellWareHouseItem(
|
||
{
|
||
id: c
|
||
},
|
||
p * this.curNum
|
||
);
|
||
}
|
||
(game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE),
|
||
game.EventManager.instance.dispatch(SysNotify.MOFAJIAGONG_UPDATA));
|
||
} else TipsUtils.showTipsDownToUp(GameConfig.ServerCode[t.status]);
|
||
}
|
||
sendNetupLevel() {
|
||
Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "factory/upgrade", {}, this.onSendnetupLevel.bind(this));
|
||
}
|
||
onSendnetupLevel(t) {
|
||
if (0 == t.status) {
|
||
const e = Global.playerProxy.playerData.factory_level,
|
||
i = Global.gameProxy.getFactoryConfigForID(e + 1);
|
||
if (i) {
|
||
const n = (Global.playerProxy.playerData.factory_exp += i.effect_plus_experience);
|
||
(n >= i.experience &&
|
||
((Global.playerProxy.playerData.factory_level += 1),
|
||
(Global.playerProxy.playerData.factory_exp = n - i.experience)),
|
||
TipsUtils.showTipsDownToUp("经验增加+" + i.effect_plus_experience));
|
||
for (const a in i)
|
||
if ("fruit_id1" == a || "fruit_id2" == a || "fruit_id3" == a || "fruit_id4" == a || "fruit_id5" == a) {
|
||
const o = i[a],
|
||
r = o.split(":"),
|
||
s = r[0],
|
||
l = int(r[1]);
|
||
"105001" == s
|
||
? (Global.playerProxy.playerData.gem -= l)
|
||
: "105002" == s
|
||
? (Global.playerProxy.playerData.gold -= l)
|
||
: "201000" == s
|
||
? (Global.playerProxy.playerData.stone -= l)
|
||
: "201001" == s
|
||
? (Global.playerProxy.playerData.steel -= l)
|
||
: Global.playerProxy.sellWareHouseItem(
|
||
{
|
||
id: s
|
||
},
|
||
l
|
||
);
|
||
}
|
||
Global.playerProxy.playerData.gold -= i.gold;
|
||
}
|
||
(game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE),
|
||
game.EventManager.instance.dispatch(SysNotify.MOFAJIAGONG_UPDATA));
|
||
} else TipsUtils.showTipsDownToUp(GameConfig.ServerCode[t.status]);
|
||
}
|
||
};
|
||
__reflect(MofaManager.prototype, "MofaManager");
|
||
var MofaProssBar = class MofaProssBar extends eui.Component {
|
||
constructor() {
|
||
super();
|
||
}
|
||
partAdded(e, i) {
|
||
super.partAdded(e, i);
|
||
}
|
||
childrenCreated() {
|
||
(super.childrenCreated(), (this.imgGroup.mask = this.imgmask));
|
||
}
|
||
setPross(t, e) {
|
||
const i = t / e;
|
||
((this.imgpross.x = this.imgpross.width * i - this.imgpross.width), (this.prossLabel.text = t + "/" + e));
|
||
}
|
||
};
|
||
__reflect(MofaProssBar.prototype, "MofaProssBar", ["eui.UIComponent", "egret.DisplayObject"]);
|
||
var SimpleItemData = class SimpleItemData {
|
||
constructor(t) {
|
||
this.config = {};
|
||
this.icons = "";
|
||
this.name = "";
|
||
this.des = "";
|
||
this.config.icon = t.graphical_id;
|
||
this.config.desc = t.desc;
|
||
this.config.name = t.name;
|
||
}
|
||
};
|
||
__reflect(SimpleItemData.prototype, "SimpleItemData");
|