1306 lines
43 KiB
JavaScript
1306 lines
43 KiB
JavaScript
var Const = class Const {
|
|
constructor() {}
|
|
static WIN_W = 640;
|
|
static WIN_H = 960;
|
|
static DESGIN_W = 640;
|
|
static DESGIN_H = 960;
|
|
static LAND_HALF_W = 97;
|
|
static LAND_HALF_H = 47;
|
|
static DIAMOND_ID = 105001;
|
|
static GOLD_ID = 105002;
|
|
static FLOW_ID = 105003;
|
|
static EX_MAX_NUMBER = 999;
|
|
static EX_OUT_FLOW_PHONE = "";
|
|
static WARE_CAPACITY = 32;
|
|
static RANK_SHOW_TYPE = 1;
|
|
static GOLD_ICON = 3002;
|
|
static DIAMOND_ICON = 3001;
|
|
};
|
|
__reflect(Const.prototype, "Const");
|
|
var game;
|
|
!(function (game) {
|
|
const CostUtils = class CostUtils {
|
|
constructor() {}
|
|
static parseCostString(costConfig) {
|
|
if (!costConfig) return [];
|
|
return String(costConfig)
|
|
.split(",")
|
|
.map(function (costItem) {
|
|
const parts = costItem.split(":"),
|
|
itemId = int(parts[0]),
|
|
count = int(parts[1]);
|
|
return itemId > 0 && count >= 0
|
|
? {
|
|
itemId: itemId,
|
|
count: count
|
|
}
|
|
: null;
|
|
})
|
|
.filter(function (costItem) {
|
|
return null !== costItem;
|
|
});
|
|
}
|
|
static normalizeCostString(costConfig, fallbackCostConfig = "") {
|
|
let costItems = CostUtils.parseCostString(costConfig);
|
|
0 === costItems.length && (costItems = CostUtils.parseCostString(fallbackCostConfig));
|
|
return costItems
|
|
.map(function (costItem) {
|
|
return costItem.itemId + ":" + costItem.count;
|
|
})
|
|
.join(",");
|
|
}
|
|
static getOwnedAmount(itemId) {
|
|
const playerData = Global.playerProxy && Global.playerProxy.playerData ? Global.playerProxy.playerData : {};
|
|
if (itemId == Const.DIAMOND_ID) return int(playerData.gem);
|
|
if (itemId == Const.GOLD_ID) return int(playerData.gold);
|
|
if (201000 == itemId) return int(playerData.stone);
|
|
if (201001 == itemId) return int(playerData.steel);
|
|
const itemData = Global.playerProxy && Global.playerProxy.getHasItemByItemId(itemId);
|
|
return itemData ? int(itemData.number) : 0;
|
|
}
|
|
static deductOwnedAmount(itemId, count) {
|
|
const playerData = Global.playerProxy && Global.playerProxy.playerData ? Global.playerProxy.playerData : {};
|
|
if (itemId == Const.DIAMOND_ID) playerData.gem = int(playerData.gem) - count;
|
|
else if (itemId == Const.GOLD_ID) playerData.gold = int(playerData.gold) - count;
|
|
else if (201000 == itemId) playerData.stone = int(playerData.stone) - count;
|
|
else if (201001 == itemId) playerData.steel = int(playerData.steel) - count;
|
|
else if (Global.playerProxy && Global.playerProxy.getHasItemByItemId(itemId))
|
|
Global.playerProxy.sellWareHouseItem(
|
|
{
|
|
id: itemId
|
|
},
|
|
count
|
|
);
|
|
}
|
|
static applyCostDeduction(costConfig) {
|
|
CostUtils.parseCostString(costConfig).forEach(function (costItem) {
|
|
costItem.count > 0 && CostUtils.deductOwnedAmount(costItem.itemId, costItem.count);
|
|
});
|
|
}
|
|
static renderCostSlots(target, costConfig, slotCount) {
|
|
const costItems = CostUtils.parseCostString(costConfig);
|
|
let missingCount = 0;
|
|
for (let slotIndex = 1; slotIndex <= slotCount; slotIndex++) {
|
|
const label = target["itemLabel" + slotIndex],
|
|
icon = target["itemIcon" + slotIndex],
|
|
costItem = costItems[slotIndex - 1];
|
|
if (!label || !icon) continue;
|
|
if (!costItem) {
|
|
label.visible = !1;
|
|
icon.visible = !1;
|
|
continue;
|
|
}
|
|
const itemConfig = Global.gameProxy.getItemConfig(costItem.itemId),
|
|
ownedAmount = CostUtils.getOwnedAmount(costItem.itemId);
|
|
((label.visible = !0),
|
|
(icon.visible = !0),
|
|
(label.text = costItem.count + ""),
|
|
(label.textColor = ownedAmount < costItem.count ? 16711680 : 7602061),
|
|
(icon.source = game.URLConfig.getIcon(itemConfig.graphical_id)),
|
|
ownedAmount < costItem.count && missingCount++);
|
|
}
|
|
return missingCount;
|
|
}
|
|
};
|
|
((game.CostUtils = CostUtils), __reflect(CostUtils.prototype, "game.CostUtils"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const PanelCommon = class PanelCommon {
|
|
constructor(t) {
|
|
this.imgBg = t.imgBg;
|
|
this.panel = t.panel;
|
|
this.imgTitle = t.imgTitle;
|
|
this.imgIcon = t.imgIcon;
|
|
this._btnClose = t.btnClose;
|
|
this.btnHelp = t.btnHelp;
|
|
this.groupHelp = t.groupHelp;
|
|
this.closeBtn = t.closeBtn;
|
|
}
|
|
setPanelWidth(t = 540) {
|
|
((this.imgBg.width = t), (this.groupHelp.right = 81 - (t - 540) / 2));
|
|
}
|
|
setPanelHeight(t = 634) {
|
|
((this.imgBg.height = t), (this.panel.height = t + 6));
|
|
}
|
|
setTitleIcon(t) {
|
|
this.imgIcon.source = t;
|
|
}
|
|
setTitle(t) {
|
|
this.imgTitle.source = t;
|
|
}
|
|
get btnClose() {
|
|
return this._btnClose;
|
|
}
|
|
setIconOffsetX(t) {
|
|
this.imgIcon.horizontalCenter = -182.5 + t;
|
|
}
|
|
};
|
|
((game.PanelCommon = PanelCommon), __reflect(PanelCommon.prototype, "game.PanelCommon"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const HouseUpgradeData = class HouseUpgradeData {
|
|
constructor(t = {}) {
|
|
this.lv = t.id;
|
|
this.items = game.CostUtils.normalizeCostString(t.item_id);
|
|
this.outAddPer = int(t.output);
|
|
this.add_exp = int(t.add_exp);
|
|
this.needPlayerLV = int(t.player_level);
|
|
}
|
|
};
|
|
((game.HouseUpgradeData = HouseUpgradeData), __reflect(HouseUpgradeData.prototype, "game.HouseUpgradeData"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LandExtentData = class LandExtentData {
|
|
constructor(t = {}) {
|
|
this.index = int(t.id) - 1;
|
|
this.lv = int(t.player_level);
|
|
this.gold = int(t.gold);
|
|
}
|
|
};
|
|
((game.LandExtentData = LandExtentData), __reflect(LandExtentData.prototype, "game.LandExtentData"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LandUpgradeData = class LandUpgradeData {
|
|
constructor(t = {}) {
|
|
this.id = t.id;
|
|
this.index = int(t.position) - 1;
|
|
this.lv = int(t.level);
|
|
this.items = game.CostUtils.normalizeCostString(t.item_id);
|
|
this.outAddPer = int(t.output);
|
|
this.expAddPer = int(t.add_exp);
|
|
}
|
|
};
|
|
((game.LandUpgradeData = LandUpgradeData), __reflect(LandUpgradeData.prototype, "game.LandUpgradeData"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LotteryData = class LotteryData {
|
|
constructor() {}
|
|
};
|
|
((game.LotteryData = LotteryData), __reflect(LotteryData.prototype, "game.LotteryData"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const RabateData = class RabateData {
|
|
constructor() {}
|
|
};
|
|
((game.RabateData = RabateData), __reflect(RabateData.prototype, "game.RabateData"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const BasePanel2 = class BasePanel2 {
|
|
constructor() {}
|
|
};
|
|
((game.BasePanel2 = BasePanel2), __reflect(BasePanel2.prototype, "game.BasePanel2"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const GamePaoMa = class GamePaoMa extends eui.Component {
|
|
constructor() {
|
|
super();
|
|
this.contentArr = [];
|
|
this.isRunning = !1;
|
|
this.skinName = new GamePaoMaSkin();
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
manager.UpdateTickerManager.instance.add(GamePaoMa._instance),
|
|
game.EventManager.instance.addEvent(SysNotify.SHOW_MESSAGE, this.showMessage, this, !0),
|
|
(this.tipsContent.mask = this.maskRect),
|
|
this.addEventListener(egret.TouchEvent.TOUCH_END, this.tipsTouchEnded, this),
|
|
(this.visible = !1));
|
|
}
|
|
update(t) {
|
|
this.contentArr.length > 0 && !this.isRunning && ((this.visible = !0), (this.isRunning = !0), this.run());
|
|
}
|
|
run() {
|
|
const t = this.contentArr.pop();
|
|
((this.tipsContent.text = t), (this.tipsContent.x = Const.WIN_W));
|
|
const e = 200 * t.length;
|
|
((this.tipsContent.visible = !0),
|
|
egret.Tween.get(this.tipsContent)
|
|
.to(
|
|
{
|
|
x: -this.tipsContent.width
|
|
},
|
|
e
|
|
)
|
|
.call(function () {
|
|
((this.visible = !1), (this.isRunning = !1));
|
|
}, this));
|
|
}
|
|
showMessage(t) {
|
|
const e = t.data;
|
|
const i = e.nickname;
|
|
const n = e.message;
|
|
const a = e.wx_id;
|
|
const o = e.phone;
|
|
let r = i + ": " + n;
|
|
(a && (r += " 私人微信 " + a), o && (r += " 电话号码 " + o), this.contentArr.push(r));
|
|
}
|
|
static get instance() {
|
|
return (GamePaoMa._instance || (GamePaoMa._instance = new GamePaoMa()), GamePaoMa._instance);
|
|
}
|
|
show() {
|
|
((this.y = 299), (this.x = Const.WIN_W / 2 - this.width / 2), GameLayerManager.instance.mainLayer.addChild(this));
|
|
}
|
|
tipsTouchEnded(t) {
|
|
window.parent && window.parent.openiframe && window.parent.openiframe(window.parent.messageUrl);
|
|
}
|
|
};
|
|
((game.GamePaoMa = GamePaoMa), __reflect(GamePaoMa.prototype, "game.GamePaoMa", ["IUpdate"]));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const GameTopLayer = class GameTopLayer extends game.BasePanel {
|
|
constructor(t) {
|
|
super();
|
|
this.contentArr = [];
|
|
this.isMine = !0;
|
|
this.gameScene = t;
|
|
this.isMine = t.isMine;
|
|
this.playerProxy = t.playerProxy;
|
|
this.skinName = new GameTopSkin();
|
|
this.top = this.horizontalCenter = 0;
|
|
this.touchEnabled = !1;
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(),
|
|
game.EventManager.instance.removeEvent(SysNotify.FRIEND_RED, this.friendpOINT, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.TOPLAYER_INFO_UPDATE, this.updateTopInfo, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.USER_EXP_CHANGE, this.showExp, this));
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), (this.imgHead.mask = this.imgHeadMask));
|
|
const i = this.playerProxy.playerData;
|
|
this.labelName.text = i.nickname;
|
|
let n = i.avatar.toString();
|
|
if ((n || (n = "1"), n.indexOf("http") > -1)) this.imgHead.source = n;
|
|
else {
|
|
const a = game.URLConfig.getHead(n);
|
|
this.imgHead.source = a;
|
|
}
|
|
(this.isMine
|
|
? (game.EventManager.instance.addEvent(SysNotify.FRIEND_RED, this.friendpOINT, this, !0),
|
|
game.EventManager.instance.addEvent(SysNotify.TOPLAYER_INFO_UPDATE, this.updateTopInfo, this, !0),
|
|
game.EventManager.instance.addEvent(SysNotify.USER_EXP_CHANGE, this.showExp, this, !0))
|
|
: ((this.groupBtn.visible = !1), (this.btnShowOrHide.visible = !1)),
|
|
(this.barExp.minimum = 0),
|
|
this.showGold(),
|
|
this.showDiamond(),
|
|
this.showExp(),
|
|
this.showgangcai(),
|
|
this.showshitou(),
|
|
this.showVip());
|
|
}
|
|
friendpOINT() {
|
|
this.friendRad.visible = !0;
|
|
}
|
|
tipsImageTouchEnded() {
|
|
window.parent && window.parent.openiframe && window.parent.openiframe(window.parent.messageUrl);
|
|
}
|
|
updateTopInfo() {
|
|
(this.showGold(), this.showDiamond(), this.showExp(), this.showshitou(), this.showgangcai(), this.showVip());
|
|
}
|
|
showExp() {
|
|
if (this.barExp) {
|
|
const t = this.playerProxy.playerData;
|
|
((this.barExp.value = t.exp),
|
|
(this.barExp.maximum = Global.gameProxy.getMaxExpByLv(t.level + 1)),
|
|
(this.labelLv.text = "LV." + t.level));
|
|
}
|
|
}
|
|
showDiamond() {
|
|
if (this.labelDiamond) {
|
|
const e = this.playerProxy.playerData;
|
|
this.labelDiamond.text = game.Utils.BigNumTostring(e.gem);
|
|
}
|
|
}
|
|
showGold() {
|
|
if (this.labelGold) {
|
|
const e = this.playerProxy.playerData;
|
|
this.labelGold.text = game.Utils.BigNumTostring(e.gold);
|
|
}
|
|
}
|
|
showgangcai() {
|
|
if (this.labelgangcai) {
|
|
const e = this.playerProxy.playerData;
|
|
this.labelgangcai.text = game.Utils.BigNumTostring(e.steel);
|
|
}
|
|
}
|
|
showshitou() {
|
|
if (this.labelshitou) {
|
|
const e = this.playerProxy.playerData;
|
|
this.labelshitou.text = game.Utils.BigNumTostring(e.stone);
|
|
}
|
|
}
|
|
showVip() {
|
|
if (this.vipbitlmapLabel) {
|
|
const t = this.playerProxy.playerData;
|
|
this.vipbitlmapLabel.text = t.vip;
|
|
}
|
|
}
|
|
onShow() {
|
|
((this.top = -this.height),
|
|
egret.Tween.get(this).to(
|
|
{
|
|
top: 0
|
|
},
|
|
250
|
|
));
|
|
}
|
|
onHide() {
|
|
egret.Tween.get(this)
|
|
.to(
|
|
{
|
|
top: -this.height
|
|
},
|
|
250
|
|
)
|
|
.call(game.UIUtils.removeSelf, this, [this]);
|
|
}
|
|
btnShowOrHideTouchEnded() {
|
|
const t = this;
|
|
((this.btnShowOrHide.touchEnabled = !1),
|
|
this.btnShowOrHide.selected
|
|
? ((this.groupBtn.visible = !0),
|
|
egret.Tween.get(this.groupBtn)
|
|
.to(
|
|
{
|
|
y: 0
|
|
},
|
|
250
|
|
)
|
|
.call(function () {
|
|
((t.btnShowOrHide.touchEnabled = !0), (t.btnShowOrHide.selected = !1));
|
|
}))
|
|
: egret.Tween.get(this.groupBtn)
|
|
.to(
|
|
{
|
|
y: -100
|
|
},
|
|
250
|
|
)
|
|
.call(function () {
|
|
((t.groupBtn.visible = !1), (t.btnShowOrHide.touchEnabled = !0), (t.btnShowOrHide.selected = !0));
|
|
}, this));
|
|
}
|
|
onTouchTap(e) {
|
|
const i = e.target;
|
|
switch (i) {
|
|
case this.imgHead:
|
|
this.isMine && game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_PLAYER_INFO);
|
|
break;
|
|
case this.btn1:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_LOG);
|
|
break;
|
|
case this.btn2:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_LAND_UPGRADE);
|
|
break;
|
|
case this.btn3:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_PAY);
|
|
break;
|
|
case this.btn4:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_LEVELGIFT);
|
|
break;
|
|
case this.btn5:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_MOFA);
|
|
break;
|
|
case this.btn9:
|
|
break;
|
|
case this.btn6:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_MOFAHECHENG);
|
|
break;
|
|
case this.btn7:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_LOTTERY);
|
|
break;
|
|
case this.btn8:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_BOX);
|
|
break;
|
|
case this.btn11:
|
|
break;
|
|
case this.btn10:
|
|
}
|
|
}
|
|
};
|
|
((game.GameTopLayer = GameTopLayer), __reflect(GameTopLayer.prototype, "game.GameTopLayer"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const GameView = class GameView extends game.BasePanel {
|
|
constructor(t) {
|
|
super();
|
|
this.currLandIndex = -1;
|
|
this.landPlantMap = new HashMap();
|
|
this.lastTouchX = -1;
|
|
this.startTouchX = -1;
|
|
this.lastTouchTime = -1;
|
|
this.isVisibleAnimate = !1;
|
|
this.gameScene = t;
|
|
this.isMine = t.isMine;
|
|
this.isMine ? (this.playerProxy = Global.playerProxy) : (this.playerProxy = Global.otherPlayerProxy);
|
|
this.isMine = this.gameScene.isMine;
|
|
this.skinName = new GameViewSkin();
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
this.isMine
|
|
? ((this.imgAdd.anchorOffsetX = 47), (this.imgAdd.anchorOffsetY = 83))
|
|
: ((this.imgAdd.touchEnabled = !1), game.UIUtils.removeSelf(this.imgAdd)),
|
|
(this.imgLandLight.touchEnabled = !1),
|
|
this.hideLandLight(),
|
|
(this.landGroup.touchEnabled = this.landGroup.touchChildren = !1),
|
|
(this.plantGroup.touchEnabled = this.plantGroup.touchChildren = !1),
|
|
(this.stateGroup.touchEnabled = this.stateGroup.touchChildren = !1),
|
|
(this.stateGroup.name = "stateGroup"),
|
|
(GameLayerManager.instance.plantStateLayer = this.stateGroup),
|
|
this.initLandCenterPos(),
|
|
this.initOpenLand(),
|
|
this.updateAllPlant(),
|
|
this.updateAddLandImg());
|
|
}
|
|
onAdded() {
|
|
(super.onAdded(),
|
|
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeganHandler, this),
|
|
this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onStageTouchTapHandler, this),
|
|
this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapHandler, this),
|
|
this.isMine
|
|
? (game.EventManager.instance.addEvent(SysNotify.PLANT_REFRESH, this.onLandPlantRefresh, this),
|
|
game.EventManager.instance.addEvent(SysNotify.LAND_REFRESH, this.onLandRefresh, this))
|
|
: game.EventManager.instance.addEvent(SysNotify.OTHER_PLANT_REFRESH, this.onLandPlantRefresh, this),
|
|
game.EventManager.instance.addEvent(SysNotify.PLANT_REAP, this.onPlantReap, this),
|
|
game.EventManager.instance.addEvent(SysNotify.COOLMENU_HIDE, this.hideLandLight, this),
|
|
game.UIUtils.addLongTouch(this, this.onLongTouchLand.bind(this), this.onLongTouchLandEnd.bind(this)));
|
|
}
|
|
onPlantReap(e) {
|
|
const i = e.data;
|
|
const n = Const.clickLandIndex;
|
|
let a = this.landCenterPosArr[n];
|
|
a = this.landGroup.localToGlobal(a.x - 50, a.y - 30);
|
|
const o = (this.playerProxy.landData, this.playerProxy.landData[n]);
|
|
game.SimpleTip.popTip(o.plantName + "x" + i, a.x, a.y, 16);
|
|
const r = this.landPlantMap.get(n);
|
|
r.showReapAnim();
|
|
}
|
|
onLandPlantRefresh(t) {
|
|
if (null != t.data) {
|
|
const e = t.data,
|
|
i = this.playerProxy.landData[e];
|
|
this.updateOnePlant(i, e);
|
|
} else this.updateAllPlant();
|
|
}
|
|
onLongTouchLand(e) {
|
|
const i = this.checkPlantOrLandClick(e.stageX - this.x, e.stageY - this.y);
|
|
if (i >= 0) {
|
|
const n = this.playerProxy.landData,
|
|
a = n[i];
|
|
if (a) {
|
|
const o = this.landCenterPosArr[i].clone();
|
|
((o.x += this.x), (o.y += this.y - 25), game.PlantCdTip.show(a, o));
|
|
}
|
|
}
|
|
}
|
|
onLongTouchLandEnd(e) {
|
|
game.PlantCdTip.hide();
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(),
|
|
this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeganHandler, this),
|
|
this.stage.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onStageTouchTapHandler, this),
|
|
this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapHandler, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.PLANT_REAP, this.onPlantReap, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.COOLMENU_HIDE, this.hideLandLight, this),
|
|
this.isMine
|
|
? game.EventManager.instance.removeEvent(SysNotify.OTHER_PLANT_REFRESH, this.onLandPlantRefresh, this)
|
|
: (game.EventManager.instance.removeEvent(SysNotify.PLANT_REFRESH, this.onLandPlantRefresh, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.LAND_REFRESH, this.onLandRefresh, this)),
|
|
game.UIUtils.removeLongTouch(this));
|
|
}
|
|
onTouchBeganHandler(e) {
|
|
(game.CoolMenu.instance.hide(),
|
|
game.PlantCdTip.hide(),
|
|
(this.lastTouchX = e.stageX),
|
|
(this.startTouchX = e.stageX),
|
|
(this.lastTouchTime = egret.getTimer()));
|
|
}
|
|
hideLandLight() {
|
|
this.imgLandLight.visible = !1;
|
|
}
|
|
onStageTouchTapHandler() {
|
|
this.hideLandLight();
|
|
}
|
|
updateAddLandImg() {
|
|
const t = _.values(this.playerProxy.landData).length;
|
|
if (t >= 12) this.imgAdd.visible = !1;
|
|
else {
|
|
this.imgAdd.visible = !0;
|
|
const e = this.landCenterPosArr[t];
|
|
((this.imgAdd.x = e.x - 10), (this.imgAdd.y = e.y));
|
|
}
|
|
}
|
|
initOpenLand() {
|
|
for (let t = 0; 12 > t; t++) {
|
|
const e = new eui.Image();
|
|
((e.x = this.landCenterPosArr[t].x - Const.LAND_HALF_W),
|
|
(e.y = this.landCenterPosArr[t].y - Const.LAND_HALF_H),
|
|
this.landGroup.addChild(e),
|
|
this.updateOneLand(t));
|
|
}
|
|
}
|
|
onLandRefresh(t) {
|
|
if (null != t.data) {
|
|
const e = t.data;
|
|
this.updateOneLand(e);
|
|
} else for (let i = Global.playerProxy.landData, n = _.values(i).length, a = 0; n > a; a++) this.updateOneLand(a);
|
|
this.updateAddLandImg();
|
|
}
|
|
updateOneLand(t) {
|
|
const e = this.playerProxy.landData;
|
|
let i = -1;
|
|
const n = e[t];
|
|
n && (i = n.landLv);
|
|
const a = this.landGroup.getChildAt(t);
|
|
a.source = "land" + i + "_png";
|
|
}
|
|
flushGameView() {
|
|
this.updateAllPlant();
|
|
}
|
|
updateAllPlant() {
|
|
const t = this.playerProxy.landData;
|
|
(this.initLandCenterPos(), this.plantGroup.removeChildren());
|
|
for (const e in t) this.updateOnePlant(t[e], e);
|
|
}
|
|
initLandCenterPos() {
|
|
this.landCenterPosArr = [];
|
|
for (let t = Const.LAND_HALF_W, e = Const.LAND_HALF_H, i = 0; 12 > i; i++) {
|
|
const n = new egret.Point();
|
|
((n.x = -(i % 3) * (t - 10) + parseInt(i / 3 + "") * t),
|
|
(n.y = (i % 3) * (e + 3) + parseInt(i / 3 + "") * e),
|
|
this.landCenterPosArr.push(n));
|
|
}
|
|
}
|
|
updateOnePlant(e, i) {
|
|
let n = (this.playerProxy.landData, this.landPlantMap.get(i));
|
|
e && e.plantId > 0
|
|
? (n
|
|
? n.changeData(e)
|
|
: ((n = new game.WidgetLand(e)),
|
|
(n.x = this.landCenterPosArr[i].x),
|
|
(n.y = this.landCenterPosArr[i].y),
|
|
this.landPlantMap.add(i, n)),
|
|
n.updateDisease(),
|
|
this.plantGroup.addChild(n))
|
|
: game.UIUtils.removeSelf(n);
|
|
}
|
|
onTouchTapHandler(e) {
|
|
if ((e.stopPropagation(), e.target == this.imgAdd))
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_LANDEXTEND);
|
|
else {
|
|
const i = this.checkPlantOrLandClick(e.localX, e.localY);
|
|
i >= 0 ? this.clickLand(i) : this.hideLandLight();
|
|
}
|
|
}
|
|
clickLand(e) {
|
|
((this.currLandIndex = e), (Const.clickLandIndex = e));
|
|
const i = this.playerProxy.landData[e],
|
|
n = this.landCenterPosArr[e],
|
|
a = n.clone();
|
|
((a.x += this.x), (a.y += this.y - 25), game.CoolMenu.instance.hide());
|
|
let o = this.getMyFarmMenu(i),
|
|
r = 0;
|
|
(this.isMine || ((o = this.getOtherFarmMenu(i)), (r = Const.WIN_W)),
|
|
game.CoolMenu.instance.show(o, a, r),
|
|
this.showLandLight(n));
|
|
}
|
|
showLandLight(t) {
|
|
((this.imgLandLight.visible = !0),
|
|
(this.imgLandLight.x = t.x - Const.LAND_HALF_W),
|
|
(this.imgLandLight.y = t.y - Const.LAND_HALF_H - 2));
|
|
}
|
|
getOtherFarmMenu(e) {
|
|
let i = [];
|
|
return (
|
|
e.status == game.PlantStatus.ripe
|
|
? (i = [MenuType.STEAL])
|
|
: e.status != game.PlantStatus.empty &&
|
|
e.status != game.PlantStatus.die &&
|
|
((i = []),
|
|
e.stateBug || (e.status != game.PlantStatus.seed && i.push(MenuType.PUT_BUG)),
|
|
e.stateGrass || i.push(MenuType.PUT_GRASS),
|
|
e.stateDry),
|
|
i
|
|
);
|
|
}
|
|
getMyFarmMenu(e) {
|
|
let i = [];
|
|
return (
|
|
e && e.status != game.PlantStatus.empty
|
|
? e.status == game.PlantStatus.die
|
|
? (i = [MenuType.UPROOT])
|
|
: e.status == game.PlantStatus.ripe
|
|
? (i = [MenuType.GAIN])
|
|
: ((i = [MenuType.UPROOT, MenuType.MANURE]),
|
|
e.stateBug && i.push(MenuType.DIE_BUG),
|
|
e.stateGrass && i.push(MenuType.DIE_GRASS),
|
|
e.stateDry && i.push(MenuType.PUT_WATER))
|
|
: (i = [MenuType.PLANT]),
|
|
i
|
|
);
|
|
}
|
|
checkPlantOrLandClick(t, e) {
|
|
for (var i = -1, n = new egret.Point(t, e), a = 0; a < this.plantGroup.numChildren; a++) {
|
|
const o = this.plantGroup.getChildAt(a),
|
|
r = o.getBoundingBox();
|
|
if (r && r.containsPoint(n)) {
|
|
i = o.landData.landId;
|
|
break;
|
|
}
|
|
}
|
|
if (0 > i)
|
|
for (let s = this.playerProxy.landData, l = _.values(s).length, a = 0; l > a; a++) {
|
|
const h = this.landCenterPosArr[a];
|
|
if (Math.abs(h.x - t) < Const.LAND_HALF_H && Math.abs(h.y - e) < Const.LAND_HALF_H) {
|
|
i = a;
|
|
break;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
};
|
|
((game.GameView = GameView), __reflect(GameView.prototype, "game.GameView"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LeftMenu = class LeftMenu extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.status = 1;
|
|
this.isWaveButtonShowing = !1;
|
|
this.isWavePlayingShowMode = !0;
|
|
this.wavePlayingAngle = 0;
|
|
this.skinName = new LeftMenuSkin();
|
|
this.bottom = this.left = 0;
|
|
}
|
|
onShow() {
|
|
((this.scaleX = this.scaleY = 0),
|
|
egret.Tween.get(this).to(
|
|
{
|
|
scaleX: 1,
|
|
scaleY: 1
|
|
},
|
|
250
|
|
));
|
|
}
|
|
onHide() {
|
|
egret.Tween.get(this)
|
|
.to(
|
|
{
|
|
scaleX: 0,
|
|
scaleY: 0
|
|
},
|
|
250
|
|
)
|
|
.call(game.UIUtils.removeSelf, this, [this]);
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), this.initWaveButton());
|
|
}
|
|
onTouchTap(t) {
|
|
switch ((t.stopPropagation(), t.target)) {
|
|
case this.btn1:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FULI);
|
|
break;
|
|
case this.btn2:
|
|
PopUpManager.popTip("敬请期待");
|
|
break;
|
|
case this.btn3:
|
|
PopUpManager.popTip("敬请期待");
|
|
break;
|
|
case this.btn4:
|
|
PopUpManager.popTip("敬请期待");
|
|
}
|
|
}
|
|
btnHomeTouchEnded() {
|
|
this.showOrHideWaveButton();
|
|
}
|
|
initWaveButton() {
|
|
((this.isWaveButtonShowing = !1),
|
|
(this.waveButtonArr = [this.btn1, this.btn2, this.btn3, this.btn4]),
|
|
(this.waveCenterPos = new egret.Point(-71.5, -69.5)),
|
|
this.visibleWaveButton(!1));
|
|
}
|
|
visibleWaveButton(t) {
|
|
this.waveButtonArr.forEach(function (e) {
|
|
((e.visible = t), t || (e.x = e.y = -1e3));
|
|
}, this);
|
|
}
|
|
showOrHideWaveButton() {
|
|
this.isWaveButtonShowing ? this.hideWave() : this.showWave();
|
|
}
|
|
onStageTap(t) {
|
|
this.hideWave();
|
|
}
|
|
showWave() {
|
|
((this.isWaveButtonShowing = !0),
|
|
(this.isWavePlayingShowMode = !0),
|
|
(this.wavePlayingAngle = 180),
|
|
this.visibleWaveButton(!0),
|
|
manager.UpdateTickerManager.instance.add(this));
|
|
}
|
|
hideWave() {
|
|
((this.isWaveButtonShowing = !1),
|
|
(this.isWavePlayingShowMode = !1),
|
|
(this.wavePlayingAngle = 10),
|
|
manager.UpdateTickerManager.instance.add(this));
|
|
}
|
|
update(e) {
|
|
const i = this;
|
|
(this.isWavePlayingShowMode
|
|
? ((this.wavePlayingAngle -= 0.4 * e),
|
|
this.wavePlayingAngle < 8 && manager.UpdateTickerManager.instance.remove(this))
|
|
: ((this.wavePlayingAngle += 0.4 * e),
|
|
this.wavePlayingAngle >= 180 &&
|
|
((this.wavePlayingAngle = 180),
|
|
manager.UpdateTickerManager.instance.remove(this),
|
|
this.visibleWaveButton(!1))),
|
|
this.waveButtonArr.forEach(function (e, n) {
|
|
const a = i.wavePlayingAngle - 35 * n,
|
|
o = game.Utils.ang2rad(a),
|
|
r = 155 * Math.cos(o) - i.waveCenterPos.x,
|
|
s = 155 * Math.sin(o) - i.waveCenterPos.y;
|
|
((e.x = r - e.width / 2), (e.y = s));
|
|
}));
|
|
}
|
|
};
|
|
((game.LeftMenu = LeftMenu), __reflect(LeftMenu.prototype, "game.LeftMenu", ["IUpdate"]));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LeftMiddleMenu = class LeftMiddleMenu extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.status = 1;
|
|
this.skinName = leftmiddleButtonSkin;
|
|
this.left = 0;
|
|
this.top = 300;
|
|
}
|
|
onShow() {
|
|
((this.scaleX = this.scaleY = 0),
|
|
egret.Tween.get(this).to(
|
|
{
|
|
scaleX: 1,
|
|
scaleY: 1
|
|
},
|
|
250
|
|
));
|
|
}
|
|
onHide() {
|
|
egret.Tween.get(this)
|
|
.to(
|
|
{
|
|
scaleX: 0,
|
|
scaleY: 0
|
|
},
|
|
250
|
|
)
|
|
.call(game.UIUtils.removeSelf, this, [this]);
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), manager.UpdateTickerManager.instance.add(this));
|
|
}
|
|
childrenCreated() {
|
|
super.childrenCreated();
|
|
}
|
|
onTouchTap(e) {
|
|
switch ((e.stopPropagation(), e.target)) {
|
|
case this.btn1:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FULI);
|
|
break;
|
|
case this.btn2:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_NOTICE);
|
|
break;
|
|
case this.btn3:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_ONLINEGIFT);
|
|
break;
|
|
case this.btn4:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SIGN);
|
|
}
|
|
}
|
|
onStageTap(t) {}
|
|
update(t) {}
|
|
};
|
|
((game.LeftMiddleMenu = LeftMiddleMenu), __reflect(LeftMiddleMenu.prototype, "game.LeftMiddleMenu", ["IUpdate"]));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const MainMenu = class MainMenu extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.status = 1;
|
|
this.isWaveButtonShowing = !1;
|
|
this.isWavePlayingShowMode = !0;
|
|
this.wavePlayingAngle = 0;
|
|
this.skinName = new MainMenuSkin();
|
|
this.bottom = this.right = 0;
|
|
}
|
|
onShow() {
|
|
((this.scaleX = this.scaleY = 0),
|
|
egret.Tween.get(this).to(
|
|
{
|
|
scaleX: 1,
|
|
scaleY: 1
|
|
},
|
|
250
|
|
));
|
|
}
|
|
onHide() {
|
|
egret.Tween.get(this)
|
|
.to(
|
|
{
|
|
scaleX: 0,
|
|
scaleY: 0
|
|
},
|
|
250
|
|
)
|
|
.call(game.UIUtils.removeSelf, this, [this]);
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), this.initWaveButton());
|
|
}
|
|
onTouchTap(e) {
|
|
switch ((e.stopPropagation(), e.target)) {
|
|
case this.btn1:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SHOP);
|
|
break;
|
|
case this.btn2:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_WARE_HOUSE);
|
|
break;
|
|
case this.btn3:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_SKIN);
|
|
break;
|
|
case this.btn4:
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FRIEND, {
|
|
index: 0
|
|
});
|
|
}
|
|
}
|
|
btnHomeTouchEnded() {
|
|
this.showOrHideWaveButton();
|
|
}
|
|
initWaveButton() {
|
|
((this.isWaveButtonShowing = !1),
|
|
(this.waveButtonArr = [this.btn1, this.btn2, this.btn3, this.btn4]),
|
|
(this.waveCenterPos = new egret.Point(
|
|
this.btnHome.x + 0.5 * this.btnHome.width,
|
|
this.btnHome.y + 0.5 * this.btnHome.height
|
|
)),
|
|
this.visibleWaveButton(!1));
|
|
}
|
|
visibleWaveButton(t) {
|
|
this.waveButtonArr.forEach(function (e) {
|
|
((e.visible = t), t || (e.x = e.y = 1e3));
|
|
}, this);
|
|
}
|
|
showOrHideWaveButton() {
|
|
this.isWaveButtonShowing ? this.hideWave() : this.showWave();
|
|
}
|
|
onStageTap(t) {
|
|
this.hideWave();
|
|
}
|
|
showWave() {
|
|
((this.isWaveButtonShowing = !0),
|
|
(this.isWavePlayingShowMode = !0),
|
|
(this.wavePlayingAngle = 180),
|
|
this.visibleWaveButton(!0),
|
|
manager.UpdateTickerManager.instance.add(this));
|
|
}
|
|
hideWave() {
|
|
((this.isWaveButtonShowing = !1),
|
|
(this.isWavePlayingShowMode = !1),
|
|
(this.wavePlayingAngle = 275),
|
|
manager.UpdateTickerManager.instance.add(this));
|
|
}
|
|
update(e) {
|
|
const i = this;
|
|
(this.isWavePlayingShowMode
|
|
? ((this.wavePlayingAngle += 0.4 * e),
|
|
this.wavePlayingAngle >= 280 &&
|
|
((this.wavePlayingAngle = 280), manager.UpdateTickerManager.instance.remove(this)))
|
|
: ((this.wavePlayingAngle -= 0.4 * e),
|
|
this.wavePlayingAngle < 135 &&
|
|
(manager.UpdateTickerManager.instance.remove(this), this.visibleWaveButton(!1))),
|
|
this.waveButtonArr.forEach(function (e, n) {
|
|
const a = i.wavePlayingAngle - 36 * n,
|
|
o = game.Utils.ang2rad(a),
|
|
r = 155 * Math.cos(o) + i.waveCenterPos.x + 50,
|
|
s = 155 * Math.sin(o) + i.waveCenterPos.y + 30;
|
|
((e.x = r), (e.y = s));
|
|
}));
|
|
}
|
|
};
|
|
((game.MainMenu = MainMenu), __reflect(MainMenu.prototype, "game.MainMenu", ["IUpdate"]));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const BagIconRender = class BagIconRender extends game.BaseItemRenderer {
|
|
constructor() {
|
|
super();
|
|
this.skinName = new BagIconSkin();
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
game.UIUtils.addLongTouch(this, this.onLongTouchBegan.bind(this), this.onLongTouchEnd.bind(this)));
|
|
}
|
|
onLongTouchBegan() {
|
|
const e = this.data;
|
|
e && game.ItemTip.show(e, this.localToGlobal(this.width / 2, this.height / 2));
|
|
}
|
|
onLongTouchEnd() {
|
|
game.ItemTip.hide();
|
|
}
|
|
dataChanged() {
|
|
((this.itemData = this.data),
|
|
(this.imgIcon.source = game.URLConfig.getIcon(this.itemData.config.icon)),
|
|
(this.labelNum.text = "x" + this.itemData.number));
|
|
}
|
|
onTouchTap(e) {
|
|
const i = Global.playerProxy.playerData;
|
|
if (i.level >= this.itemData.config.lv) {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_BAG);
|
|
const n = game.AppFacade.getInstance().retrieveMediator(game.GameMediator.NAME);
|
|
this.itemData.config.smallType == SmallType.MANURE
|
|
? n.useFertilize(this.itemData.config)
|
|
: n.plantSeed(Const.clickLandIndex, this.itemData.config);
|
|
} else TipsUtils.showTipsDownToUp("等级不足", !0);
|
|
}
|
|
};
|
|
((game.BagIconRender = BagIconRender), __reflect(BagIconRender.prototype, "game.BagIconRender"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const CoolMenu = class CoolMenu extends eui.Group {
|
|
constructor() {
|
|
super();
|
|
this.touchEnabled = !1;
|
|
}
|
|
static get instance() {
|
|
return (CoolMenu._instance || (CoolMenu._instance = new CoolMenu()), CoolMenu._instance);
|
|
}
|
|
show(e, i, n) {
|
|
if ((void 0 === n && (n = 0), (this.fromPos = i), this.removeChildren(), e && e.length && 0 != e.length))
|
|
if (0 == e.length) new game.CoolMenuItem(e[0]).execute();
|
|
else {
|
|
const a = e.length;
|
|
let o = -90;
|
|
i.x < 150 && a > 2 ? (o = 0) : i.x > Const.WIN_W - 150 && a > 2 && (o = 180);
|
|
let r = 50,
|
|
s = 110;
|
|
a >= 2
|
|
? (2 == a
|
|
? (r = 55)
|
|
: 3 == a
|
|
? (r = 72)
|
|
: (4 == a && (s = 95),
|
|
(r = 360 / a),
|
|
(i.x < 150 || i.x > Const.WIN_W - 150) && ((r = 270 / a), 5 == a && (s = 125))),
|
|
(o -= ((a - 1) * r) / 2))
|
|
: (s = 60);
|
|
for (let l = 0; a > l; l++) {
|
|
const h = new game.CoolMenuItem(e[l]),
|
|
c = game.Utils.ang2rad(o + l * r),
|
|
p = Math.cos(c) * s + i.x + n,
|
|
d = Math.sin(c) * s + i.y;
|
|
((h.x = i.x + n),
|
|
(h.y = i.y),
|
|
this.addChild(h),
|
|
egret.Tween.get(h).to(
|
|
{
|
|
x: p,
|
|
y: d
|
|
},
|
|
200,
|
|
egret.Ease.backOut
|
|
));
|
|
}
|
|
((this.fromPos.x += n),
|
|
GameLayerManager.instance.popLayer.addChild(this),
|
|
Const.stage.once(egret.TouchEvent.TOUCH_BEGIN, this.onStageTouch, this, !1, -1));
|
|
}
|
|
}
|
|
onStageTouch(t) {
|
|
this.hide(!0);
|
|
}
|
|
hide(e) {
|
|
const i = this;
|
|
if (
|
|
(void 0 === e && (e = !1),
|
|
Const.stage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageTouch, this),
|
|
e && this.numChildren > 0)
|
|
) {
|
|
for (let n = 0; n < this.numChildren; n++) {
|
|
const a = this.getChildAt(n);
|
|
egret.Tween.get(a).to(
|
|
{
|
|
x: this.fromPos.x,
|
|
y: this.fromPos.y
|
|
},
|
|
200,
|
|
egret.Ease.backIn
|
|
);
|
|
}
|
|
(egret.setTimeout(
|
|
function () {
|
|
game.UIUtils.removeSelf(i);
|
|
},
|
|
this,
|
|
200
|
|
),
|
|
game.AppFacade.getInstance().sendNotification(SysNotify.COOLMENU_HIDE));
|
|
} else game.UIUtils.removeSelf(this);
|
|
}
|
|
};
|
|
((game.CoolMenu = CoolMenu), __reflect(CoolMenu.prototype, "game.CoolMenu"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const CoolMenuItem = class CoolMenuItem extends eui.Image {
|
|
constructor(i) {
|
|
super("menu_p_" + i + "_png");
|
|
this.anchorOffsetX = 46;
|
|
this.anchorOffsetY = 44;
|
|
this.type = i;
|
|
game.UIUtils.addButtonScaleEffects(this, !0);
|
|
this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapHandler, this);
|
|
this.once(egret.Event.REMOVED_FROM_STAGE, this.onRemoved, this);
|
|
}
|
|
onRemoved(e) {
|
|
(game.UIUtils.removeButtonScaleEffects(this, !0),
|
|
this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapHandler, this));
|
|
}
|
|
onTouchTapHandler(e) {
|
|
this.execute();
|
|
const i = game.UIUtils.getParentByClass(this, game.CoolMenu);
|
|
(i.hide(!0), e.stopPropagation(), e.stopImmediatePropagation());
|
|
}
|
|
execute() {
|
|
switch (this.type) {
|
|
case MenuType.PLANT:
|
|
this.plant();
|
|
break;
|
|
case MenuType.GAIN:
|
|
this.gain();
|
|
break;
|
|
case MenuType.STEAL:
|
|
this.steal();
|
|
break;
|
|
case MenuType.UPROOT:
|
|
this.uproot();
|
|
break;
|
|
case MenuType.DIE_BUG:
|
|
this.dieBug();
|
|
break;
|
|
case MenuType.DIE_GRASS:
|
|
this.dieGrass();
|
|
break;
|
|
case MenuType.PUT_WATER:
|
|
this.putWater();
|
|
break;
|
|
case MenuType.PUT_GRASS:
|
|
this.putGrass();
|
|
break;
|
|
case MenuType.PUT_BUG:
|
|
this.putBug();
|
|
break;
|
|
case MenuType.MANURE:
|
|
this.manure();
|
|
}
|
|
}
|
|
plant() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_BAG, {
|
|
type: ItemType.SEED
|
|
});
|
|
}
|
|
gain() {
|
|
game.AppFacade.getInstance().sendNotification(ClientNotify.LAND_SHOUHUO);
|
|
}
|
|
steal() {
|
|
const e = Global.otherPlayerProxy.playerData,
|
|
i = e.id > 0 ? e.id : 0;
|
|
if (i > 0) {
|
|
const n = function (e, i) {
|
|
const n = e.steal_count,
|
|
a = e.deduct_gold;
|
|
if (a > 0)
|
|
((Global.playerProxy.playerData.gold -= a),
|
|
PopUpManager.popTip("偷菜不幸被狗狗发现,逃跑过程中遗落了" + a + "金币"),
|
|
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
|
|
else {
|
|
const o = Global.otherPlayerProxy.getLandByIndex(i),
|
|
r = {
|
|
item_id: o.plantConfig.outputId
|
|
};
|
|
(Global.playerProxy.updateWareHouseItem(r, n), PopUpManager.popTip("偷取" + o.plantConfig.name + "x" + n));
|
|
}
|
|
};
|
|
game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: i,
|
|
type: 0,
|
|
callback: n
|
|
});
|
|
}
|
|
}
|
|
uproot() {
|
|
game.AppFacade.getInstance().sendNotification(ClientNotify.LAND_CHANCHU);
|
|
}
|
|
dieBug() {
|
|
const e = Global.otherPlayerProxy.playerData,
|
|
i = e.id > 0 ? e.id : 0;
|
|
i > 0
|
|
? game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: i,
|
|
type: 4
|
|
})
|
|
: game.AppFacade.getInstance().sendNotification(ClientNotify.KICK_BUG, {
|
|
uid: i
|
|
});
|
|
}
|
|
putBug() {
|
|
const e = Global.otherPlayerProxy.playerData.id;
|
|
e &&
|
|
game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: e,
|
|
type: 1
|
|
});
|
|
}
|
|
dieGrass() {
|
|
const e = Global.otherPlayerProxy.playerData,
|
|
i = e.id > 0 ? e.id : 0;
|
|
i > 0
|
|
? game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: i,
|
|
type: 5
|
|
})
|
|
: game.AppFacade.getInstance().sendNotification(ClientNotify.KICK_GRASS, {
|
|
uid: i
|
|
});
|
|
}
|
|
putGrass() {
|
|
const e = Global.otherPlayerProxy.playerData,
|
|
i = e.id > 0 ? e.id : 0;
|
|
i > 0 &&
|
|
game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: i,
|
|
type: 2
|
|
});
|
|
}
|
|
putWater() {
|
|
const e = Global.otherPlayerProxy.playerData,
|
|
i = e.id > 0 ? e.id : 0;
|
|
i > 0
|
|
? game.AppFacade.getInstance().sendNotification(ClientNotify.GAO_SHI, {
|
|
id: i,
|
|
type: 3
|
|
})
|
|
: game.AppFacade.getInstance().sendNotification(ClientNotify.KICK_WATER, {
|
|
uid: i
|
|
});
|
|
}
|
|
manure() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_BAG, {
|
|
type: ItemType.PROPS
|
|
});
|
|
}
|
|
};
|
|
((game.CoolMenuItem = CoolMenuItem), __reflect(CoolMenuItem.prototype, "game.CoolMenuItem"));
|
|
})(game || (game = {}));
|
|
var MenuType = {
|
|
PLANT: "plant",
|
|
GAIN: "gain",
|
|
STEAL: "steal",
|
|
UPROOT: "uproot",
|
|
DIE_BUG: "die_bug",
|
|
DIE_GRASS: "die_grass",
|
|
PUT_WATER: "put_water",
|
|
PUT_BUG: "put_bug",
|
|
PUT_GRASS: "put_grass",
|
|
MANURE: "manure"
|
|
};
|
|
var game;
|
|
!(function (game) {
|
|
const DogItemRender = class DogItemRender extends game.BaseItemRenderer {
|
|
constructor() {
|
|
super();
|
|
this.isHungry = null;
|
|
this.skinName = new DogListItemSkin();
|
|
}
|
|
createChildren() {
|
|
super.createChildren();
|
|
}
|
|
dataChanged() {
|
|
const e = this.data;
|
|
this.labelName.text = e.config.name;
|
|
const i = Global.playerProxy.playerData.use_dog_item_id,
|
|
n = i == e.config.id;
|
|
if (
|
|
((this.imgHead.source = game.URLConfig.getIcon(e.config.icon)),
|
|
(this.btnSwitch.visible = !n),
|
|
(this.foodBtn.visible = n),
|
|
n)
|
|
) {
|
|
const a = Global.playerProxy.playerData.dog_hunger_end_time,
|
|
o = DateTimer.instance.now;
|
|
o > a
|
|
? ((this.isHungry = !0), (this.labelTime.text = "没有狗粮了"))
|
|
: (this.labelTime.text = TimeFormat.showDDHH(1e3 * (a - o)));
|
|
} else this.labelTime.text = "狗狗没有上场";
|
|
this.labelDesc.text = e.config.desc;
|
|
}
|
|
onTouchTap(t) {
|
|
switch ((t.stopPropagation(), t.target)) {
|
|
case this.btnSwitch:
|
|
this.swith();
|
|
break;
|
|
case this.foodBtn:
|
|
this.foodBtnTouchEnded();
|
|
}
|
|
}
|
|
swith() {
|
|
const e = GameConfig.SERVER_PATH + "comm/use-dog",
|
|
i = {
|
|
item_id: this.data.config.id
|
|
};
|
|
Global.netProxy.sendRequest(e, i, function (e) {
|
|
0 == e.status &&
|
|
((Global.playerProxy.playerData.use_dog_item_id = i.item_id),
|
|
game.EventManager.instance.dispatch(SysNotify.DOG_ENDTIME_CHANGE),
|
|
game.EventManager.instance.dispatch(SysNotify.USER_DOG_CHANGE));
|
|
});
|
|
}
|
|
foodBtnTouchEnded() {
|
|
const e = this,
|
|
i = GameConfig.SERVER_PATH + "user/feed-dog",
|
|
n = Global.playerProxy.getItemBySmallType(SmallType.DOG_FOOD);
|
|
if (n.length < 1) return void PopUpManager.popTip("狗粮不足");
|
|
const a = n[0];
|
|
Global.netProxy.sendRequest(
|
|
i,
|
|
{
|
|
item_id: a.config.id
|
|
},
|
|
function (i) {
|
|
0 == i.status
|
|
? ((Global.playerProxy.playerData.dog_hunger_end_time = i.data.dog_hunger_end_time),
|
|
game.EventManager.instance.dispatch(SysNotify.DOG_ENDTIME_CHANGE),
|
|
e.isHungry && ((e.isHungry = !1), game.EventManager.instance.dispatch(SysNotify.USER_DOG_CHANGE)))
|
|
: TipsUtils.showErrorCodeTips(i.status);
|
|
}
|
|
);
|
|
}
|
|
};
|
|
((game.DogItemRender = DogItemRender), __reflect(DogItemRender.prototype, "game.DogItemRender"));
|
|
})(game || (game = {}));
|