800 lines
28 KiB
JavaScript
800 lines
28 KiB
JavaScript
var game;
|
|
!(function (game) {
|
|
const CreateRoleScene = class CreateRoleScene extends game.BaseComponent {
|
|
constructor() {
|
|
super();
|
|
this.selectIconId = 1;
|
|
this.skinName = new CreateRoleSceneSkin();
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), this.setSelectHeadIcon((game.Utils.rang(1, 6e4) % 6) + 1));
|
|
}
|
|
setSelectHeadIcon(t) {
|
|
this.selectIconId = t;
|
|
for (let e = 1; 6 >= e; e++) {
|
|
const i = this["groupHead" + e];
|
|
((i.touchChildren = !1), (i.name = "groupHead" + e));
|
|
const n = i.getChildByName("imgSelect");
|
|
n.visible = t == e;
|
|
}
|
|
}
|
|
onTouchTap(t) {
|
|
switch (t.target) {
|
|
case this.btnOk:
|
|
this.createRole();
|
|
}
|
|
const e = t.target.name;
|
|
if (e.indexOf("groupHead") > -1) {
|
|
const i = parseInt(e.replace("groupHead", ""));
|
|
this.setSelectHeadIcon(i);
|
|
}
|
|
}
|
|
createRole() {
|
|
const e = this.inpName.text.trim();
|
|
if (!e) return void TipsUtils.showTipsDownToUp("请输入名称", !0);
|
|
if (e.length > 7) TipsUtils.showTipsDownToUp("输入的名称太长了", !0);
|
|
else {
|
|
const i = GameConfig.SERVER_PATH + "user/modify-user-info",
|
|
n = {
|
|
nickname: e,
|
|
avatar: this.selectIconId + ""
|
|
};
|
|
Global.netProxy.sendRequest(i, n, function (i) {
|
|
return 0 === i.status
|
|
? (Global.playerProxy.setPlayerDataProperty("nickname", e),
|
|
Global.playerProxy.setPlayerDataProperty("avatar", n.avatar),
|
|
TipsUtils.showTipsDownToUp("创建成功"),
|
|
game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_CREATEROLE),
|
|
void game.AppFacade.getInstance().sendNotification(SceneNotify.OPEN_MINE_GAME))
|
|
: void TipsUtils.showTipsDownToUp(GameConfig.ServerCode[i.status], !0);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
((game.CreateRoleScene = CreateRoleScene), __reflect(CreateRoleScene.prototype, "game.CreateRoleScene"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const GameScene = class GameScene extends game.BaseComponent {
|
|
constructor(t) {
|
|
super();
|
|
this.isMine = t;
|
|
this.isMine ? (this.playerProxy = Global.playerProxy) : (this.playerProxy = Global.otherPlayerProxy);
|
|
this.skinName = new GameSceneSkin();
|
|
}
|
|
update(t) {}
|
|
flushGameScene() {
|
|
this.isMine && (this.topLayer.updateTopInfo(), this.gameView.flushGameView());
|
|
}
|
|
changeDog() {
|
|
(game.UIUtils.removeSelf(this.widgetDog), (this.widgetDog = null), this.showDog());
|
|
}
|
|
onAdded() {
|
|
(super.onAdded(),
|
|
manager.UpdateTickerManager.instance.add(this),
|
|
this.isMine &&
|
|
(game.EventManager.instance.addEvent(SysNotify.USER_HOUSE_CHANGE, this.updateHouse, this),
|
|
game.EventManager.instance.addEvent(SysNotify.USER_SKIN_CHANGE, this.updateGround, this),
|
|
game.EventManager.instance.addEvent(SysNotify.USER_DOG_CHANGE, this.changeDog, this),
|
|
this.updateTimer ||
|
|
((this.updateTimer = new egret.Timer(6e4, Number.MAX_VALUE)),
|
|
this.updateTimer.addEventListener(egret.TimerEvent.TIMER, this.onUpdatePlantTimer, this)),
|
|
this.updateTimer.reset(),
|
|
this.updateTimer.start()));
|
|
}
|
|
onRemoved() {
|
|
(super.onRemoved(),
|
|
manager.UpdateTickerManager.instance.remove(this),
|
|
this.updateTimer ||
|
|
(game.EventManager.instance.removeEvent(SysNotify.USER_HOUSE_CHANGE, this.updateHouse, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.USER_SKIN_CHANGE, this.updateGround, this),
|
|
game.EventManager.instance.removeEvent(SysNotify.USER_DOG_CHANGE, this.changeDog, this),
|
|
this.updateTimer && this.updateTimer.stop()));
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(),
|
|
(this.imgHouse = new eui.Image()),
|
|
this.groupHouse.addChild(this.imgHouse),
|
|
this.updateHouse(),
|
|
this.showDog(),
|
|
this.updateGround(!1),
|
|
(this.gameView = new game.GameView(this)),
|
|
this.addChild(this.gameView),
|
|
(this.gameView.x = 280),
|
|
(this.gameView.y = Const.WIN_H - 460),
|
|
(this.imgFenceFront.touchEnabled = this.imgFenceBack.touchEnabled = !1),
|
|
this.addChild(this.imgFenceFront),
|
|
this.isMine
|
|
? ((this.leftMenu = new game.LeftMenu()),
|
|
this.addChild(this.leftMenu),
|
|
(this.mainMenu = new game.MainMenu()),
|
|
this.addChild(this.mainMenu),
|
|
(this.btnBackHome.visible = !1),
|
|
(this.leftMiddleMenu = new game.LeftMiddleMenu()),
|
|
this.addChild(this.leftMiddleMenu))
|
|
: ((this.btnBackHome.visible = !0), this.addChild(this.btnBackHome)),
|
|
(this.topLayer = new game.GameTopLayer(this)),
|
|
this.addChild(this.topLayer),
|
|
this.resizeSmallScreen());
|
|
}
|
|
onUpdatePlantTimer() {
|
|
this.isMine && game.AppFacade.getInstance().sendNotification(ClientNotify.FLUSH_FARM);
|
|
}
|
|
onTouchTap(e) {
|
|
switch (e.target) {
|
|
case this.btnBackHome:
|
|
(Global.otherPlayerProxy.clearPlayerData(),
|
|
game.AppFacade.getInstance().sendNotification(SceneNotify.BACK_MINE_GAME));
|
|
break;
|
|
case this.imgDogHouse:
|
|
this.isMine && game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_DOG);
|
|
break;
|
|
case this.imgHouse:
|
|
this.isMine && game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_HOUSEUPGRADE);
|
|
}
|
|
}
|
|
resizeSmallScreen() {
|
|
if (GameConfig.curHeight() < 1080) {
|
|
const t = GameConfig.curHeight() - 1080;
|
|
((this.imgGround.bottom += t),
|
|
(this.groupHouse.bottom += t),
|
|
(this.imgFenceBack.bottom += t),
|
|
(this.imgFenceFront.bottom += t),
|
|
(this.groupDog.bottom += t),
|
|
(this.imgFenceFront.left = this.imgFenceFront.right = 0),
|
|
(this.gameView.y -= t),
|
|
(this.imgGround.top = 0));
|
|
}
|
|
}
|
|
showDog() {
|
|
const e = this.playerProxy.playerData.use_dog_item_id;
|
|
0 !== e &&
|
|
((this.widgetDog = new game.WidgetDog(this.playerProxy)),
|
|
this.widgetDog.showType(e),
|
|
this.groupDog.addChild(this.widgetDog),
|
|
this.widgetDog.runTypeAni());
|
|
}
|
|
updateHouse(e) {
|
|
const i = this;
|
|
void 0 === e && (e = null);
|
|
const n = this.playerProxy.playerData;
|
|
let a = n.farm_level;
|
|
(e && e.data && (a = e.data), (a = game.Utils.limit(a, 1, 12)), (n.farm_level = a));
|
|
const o = game.URLConfig.getHouse(a);
|
|
RES.getResByUrl(
|
|
o,
|
|
function (t) {
|
|
if (t) {
|
|
const e = t.textureWidth,
|
|
n = t.textureHeight;
|
|
((i.imgHouse.source = t), (i.imgHouse.anchorOffsetX = 0.46 * e), (i.imgHouse.anchorOffsetY = 0.8673 * n));
|
|
}
|
|
},
|
|
this
|
|
);
|
|
}
|
|
updateGround(e = !0) {
|
|
const i = this.playerProxy.playerData,
|
|
n = Global.gameProxy.getItemImageId(i.bg_image_id);
|
|
((this.imgGround.source = game.URLConfig.getGround(n)),
|
|
(this.imgFenceFront.source = game.URLConfig.getGroundFenceFront(n)),
|
|
(this.imgFenceBack.source = game.URLConfig.getGroundFenceBack(n)),
|
|
e ||
|
|
(GameConfig.curHeight() > 1024
|
|
? ((this.imgGround.scale9Grid = new egret.Rectangle(0, 1, 1, 1)), (this.imgGround.top = 0))
|
|
: ((this.imgGround.scale9Grid = null), (this.imgGround.top = 0 / 0))));
|
|
}
|
|
};
|
|
((game.GameScene = GameScene), __reflect(GameScene.prototype, "game.GameScene", ["IUpdate"]));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LoginScene = class LoginScene extends game.BaseComponent {
|
|
constructor() {
|
|
super();
|
|
this.skinName = new LoginSceneSkin();
|
|
}
|
|
createChildren() {
|
|
super.createChildren();
|
|
const t = NativeApi.getLocalData("usernames");
|
|
if (t) {
|
|
const i = t.split(":"),
|
|
n = i[0];
|
|
if (n) {
|
|
const a = n.split(",");
|
|
((this.inpKey.text = a[0]), (this.inpPw.text = a[1]));
|
|
}
|
|
}
|
|
((this.inpPw.displayAsPassword = !0), (this.usernameGroup.visible = !1));
|
|
}
|
|
xialaImageTouchEnded() {
|
|
this.usernameGroup.visible = !this.usernameGroup.visible;
|
|
const t = NativeApi.getLocalData("usernames");
|
|
if (t)
|
|
for (let e = t.split(":"), i = 0; i < e.length; i++) {
|
|
const n = e[i].split(",");
|
|
n && (this["label" + (i + 1)].text = n[0]);
|
|
}
|
|
}
|
|
label1TouchEnded() {
|
|
this.showUser(1);
|
|
}
|
|
label2TouchEnded() {
|
|
this.showUser(2);
|
|
}
|
|
label3TouchEnded() {
|
|
this.showUser(3);
|
|
}
|
|
label4TouchEnded() {
|
|
this.showUser(4);
|
|
}
|
|
showUser(t) {
|
|
const e = NativeApi.getLocalData("usernames"),
|
|
i = e.split(":"),
|
|
n = i[t - 1],
|
|
a = n.split(",");
|
|
((this.inpKey.text = a[0]), (this.inpPw.text = a[1]), (this.usernameGroup.visible = !1));
|
|
}
|
|
btnRegTouchEnded() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_REGIST);
|
|
}
|
|
btnFindpwdTouchEnded() {
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FIND_PASSWORD);
|
|
}
|
|
setPlayerDataLocal(e, i) {
|
|
const n = e + "," + i,
|
|
a = NativeApi.getLocalData("usernames");
|
|
if (a) {
|
|
const o = a.split(":");
|
|
(o.indexOf(n) > -1 && game.Utils.removeArrayItem(o, n), o.unshift(n));
|
|
for (var r = "", s = 0; s < o.length && !(s > 3); s++) r += o[s] + ":";
|
|
((r = r.substring(0, r.length - 1)), NativeApi.setLocalData("usernames", r));
|
|
} else NativeApi.setLocalData("usernames", n);
|
|
}
|
|
async btnLoginTouchEnded() {
|
|
Global.audioProxy.openSound(!1);
|
|
const username = this.inpKey.text;
|
|
const password = this.inpPw.text;
|
|
if (!username || !password) {
|
|
TipsUtils.showTipsDownToUp("请输入账号", !0);
|
|
return;
|
|
}
|
|
|
|
Global.netProxy.setToken(null);
|
|
const loginData = {
|
|
username,
|
|
password
|
|
};
|
|
Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "user/login", loginData, (response) => {
|
|
if (0 === response.status) {
|
|
Global.netProxy.setToken(response.data.token);
|
|
TipsUtils.showTipsDownToUp("登陆成功");
|
|
Global.playerProxy.setPlayerData(response.data);
|
|
this.check2.selected
|
|
? this.setPlayerDataLocal(username, password)
|
|
: this.check1.selected && this.setPlayerDataLocal(username, "");
|
|
Global.gameProxy.getGameConfigJson(() => {
|
|
Global.playerProxy.setPlayerLandData(response.data);
|
|
GiftManager.getInstance().initData();
|
|
Global.playerProxy.getPlayerStoreHouse(() => {
|
|
game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_LOGIN);
|
|
game.GamePaoMa.instance.show();
|
|
window.parent &&
|
|
window.parent.openiframe &&
|
|
window.parent.gonggaoUrl &&
|
|
window.parent.openiframe(window.parent.gonggaoUrl);
|
|
response.data.nickname
|
|
? game.AppFacade.getInstance().sendNotification(SceneNotify.OPEN_MINE_GAME)
|
|
: game.AppFacade.getInstance().sendNotification(SceneNotify.OPEN_CREATEROLE);
|
|
});
|
|
});
|
|
}
|
|
TipsUtils.showTipsDownToUp(GameConfig.ServerCode[response.status], !0);
|
|
});
|
|
}
|
|
};
|
|
((game.LoginScene = LoginScene), __reflect(LoginScene.prototype, "game.LoginScene"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LogoScene = class LogoScene extends game.BaseComponent {
|
|
constructor() {
|
|
super();
|
|
this.maxLength = 0;
|
|
this.skinName = new LogoSceneSkin();
|
|
}
|
|
createChildren() {
|
|
(super.createChildren(), (this.resGroup = "main"), (this.maxLength = 560), this.beganLoadResGroup());
|
|
}
|
|
beganLoadResGroup() {
|
|
((this.startTime = new Date().getTime()),
|
|
RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this),
|
|
RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadComplete, this),
|
|
RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this),
|
|
RES.loadGroup(this.resGroup));
|
|
}
|
|
onResourceLoadComplete(t) {
|
|
t.groupName == this.resGroup &&
|
|
(RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this),
|
|
RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadComplete, this),
|
|
RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this),
|
|
this.onResourceLoadOver());
|
|
}
|
|
onResourceProgress(t) {
|
|
if (t.groupName == this.resGroup) {
|
|
const e = t.itemsLoaded / t.itemsTotal;
|
|
((this.progressBar.width = this.maxLength * e), (this.textLabel.text = Math.floor(100 * e) + "%"));
|
|
}
|
|
}
|
|
onResourceLoadOver() {
|
|
const e = new Date().getTime();
|
|
e - this.startTime;
|
|
egret.Tween.get(this)
|
|
.to(
|
|
{
|
|
alpha: 0
|
|
},
|
|
1e3
|
|
)
|
|
.call(function () {
|
|
(game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_LOADING),
|
|
game.AppFacade.getInstance().sendNotification(SceneNotify.OPEN_LOGIN));
|
|
}, this);
|
|
}
|
|
};
|
|
((game.LogoScene = LogoScene), __reflect(LogoScene.prototype, "game.LogoScene"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const SayScene = class SayScene extends game.BasePanel {
|
|
constructor() {
|
|
super();
|
|
this.skinName = new SaySceneSkin();
|
|
}
|
|
createChildren() {
|
|
super.createChildren();
|
|
}
|
|
onTouchTap() {
|
|
game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_SAY);
|
|
}
|
|
};
|
|
((game.SayScene = SayScene), __reflect(SayScene.prototype, "game.SayScene"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const CreateRoleMediator = class CreateRoleMediator extends BaseMediator {
|
|
constructor() {
|
|
super(CreateRoleMediator.NAME);
|
|
this.type = "scene";
|
|
}
|
|
listNotificationInterests() {
|
|
return [SceneNotify.OPEN_CREATEROLE, SceneNotify.CLOSE_CREATEROLE];
|
|
}
|
|
onRegister() {
|
|
super.onRegister();
|
|
}
|
|
showViewComponent() {
|
|
this.viewComponent = new game.CreateRoleScene();
|
|
const e = GameLayerManager.gameLayer().sceneLayer;
|
|
e.addChild(this.viewComponent);
|
|
}
|
|
handleNotification(t) {
|
|
switch (t.getName()) {
|
|
case SceneNotify.OPEN_CREATEROLE:
|
|
this.showViewComponent();
|
|
break;
|
|
case SceneNotify.CLOSE_CREATEROLE:
|
|
this.closeViewComponent(1);
|
|
}
|
|
}
|
|
static NAME = "CreateRoleMediator";
|
|
};
|
|
((game.CreateRoleMediator = CreateRoleMediator), __reflect(CreateRoleMediator.prototype, "game.CreateRoleMediator"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const GameMediator = class GameMediator extends BaseMediator {
|
|
constructor(t = null) {
|
|
super(GameMediator.NAME, t);
|
|
this.type = "scene";
|
|
}
|
|
listNotificationInterests() {
|
|
return [
|
|
SceneNotify.OPEN_MINE_GAME,
|
|
SceneNotify.OPEN_OTHER_GAME,
|
|
SceneNotify.BACK_MINE_GAME,
|
|
SceneNotify.CLOSE_GAME,
|
|
ClientNotify.LAND_SHOUHUO,
|
|
ClientNotify.LAND_CHANCHU,
|
|
ClientNotify.FLUSH_FARM,
|
|
ClientNotify.KICK_BUG,
|
|
ClientNotify.KICK_GRASS,
|
|
ClientNotify.KICK_WATER,
|
|
ClientNotify.GAO_SHI,
|
|
ClientNotify.USE_FERTILIZE
|
|
];
|
|
}
|
|
onRegister() {
|
|
(super.onRegister(),
|
|
this.facade.registerMediator(new game.ShopMediator()),
|
|
this.facade.registerMediator(new game.WareHouseMediator()),
|
|
this.facade.registerMediator(new game.BagMediator()),
|
|
this.facade.registerMediator(new game.SkinMediator()),
|
|
this.facade.registerMediator(new game.HelpMediator()),
|
|
this.facade.registerMediator(new game.LandExtendMediator()),
|
|
this.facade.registerMediator(new game.LandUpgradeMediator()),
|
|
this.facade.registerMediator(new game.HouseUpgradeMediator()),
|
|
this.facade.registerMediator(new game.DogMediator()),
|
|
this.facade.registerMediator(new game.FriendMediator()),
|
|
this.facade.registerMediator(new game.PlayerInfoMediator()),
|
|
this.facade.registerMediator(new game.LogMediator()),
|
|
this.facade.registerMediator(new game.FriendGiveMediator()),
|
|
this.facade.registerMediator(new game.FriendGiveListMediator()),
|
|
this.facade.registerMediator(new game.LotteryMediator()),
|
|
this.facade.registerMediator(new game.SendMesageMediator()),
|
|
this.facade.registerMediator(new game.SayMediator()),
|
|
this.facade.registerMediator(new game.ExGoldMediator()),
|
|
this.facade.registerMediator(new game.PayMediator()),
|
|
this.facade.registerMediator(new game.NoticeMediator()),
|
|
this.facade.registerMediator(new BoxMediator()),
|
|
this.facade.registerMediator(new SignMediter()),
|
|
this.facade.registerMediator(new SignsTipsMediter()),
|
|
this.facade.registerMediator(new FuliMediter()),
|
|
this.facade.registerMediator(new FulibaoTipsMediter()),
|
|
this.facade.registerMediator(new game.MofajiagongMediter()),
|
|
this.facade.registerMediator(new game.MofahechengMidter()),
|
|
this.facade.registerMediator(new LevelGiftMediter()),
|
|
this.facade.registerMediator(new OnlineGiftMediter()));
|
|
}
|
|
handleNotification(t) {
|
|
const e = t.getBody();
|
|
switch (t.getName()) {
|
|
case SceneNotify.OPEN_MINE_GAME:
|
|
this.showViewComponent(!0);
|
|
break;
|
|
case SceneNotify.OPEN_OTHER_GAME:
|
|
this.showOtherGameScene();
|
|
break;
|
|
case SceneNotify.BACK_MINE_GAME:
|
|
this.backToMineScene();
|
|
break;
|
|
case SceneNotify.CLOSE_GAME:
|
|
this.closeViewComponent(1);
|
|
break;
|
|
case ClientNotify.LAND_SHOUHUO:
|
|
this.shouhuo();
|
|
break;
|
|
case ClientNotify.LAND_CHANCHU:
|
|
this.chanchu();
|
|
break;
|
|
case ClientNotify.FLUSH_FARM:
|
|
this.flushFarm();
|
|
break;
|
|
case ClientNotify.KICK_BUG:
|
|
this.kickDisease(1);
|
|
break;
|
|
case ClientNotify.KICK_GRASS:
|
|
this.kickDisease(2);
|
|
break;
|
|
case ClientNotify.KICK_WATER:
|
|
this.kickDisease(0);
|
|
break;
|
|
case ClientNotify.GAO_SHI:
|
|
this.putOtherPlayerAction(e);
|
|
}
|
|
}
|
|
putOtherPlayerAction(t) {
|
|
const e = GameConfig.SERVER_PATH + "interaction/interaction",
|
|
i = Const.clickLandIndex,
|
|
n = {
|
|
type: t.type,
|
|
be_user_id: t.id,
|
|
position: i
|
|
};
|
|
Global.netProxy.sendRequest(e, n, function (e) {
|
|
if (0 === e.status) {
|
|
switch (e.data.type) {
|
|
case 1:
|
|
PopUpManager.popTip("放虫成功");
|
|
break;
|
|
case 2:
|
|
PopUpManager.popTip("放草成功");
|
|
break;
|
|
case 3:
|
|
PopUpManager.popTip("浇水成功");
|
|
break;
|
|
case 4:
|
|
PopUpManager.popTip("除虫成功");
|
|
break;
|
|
case 5:
|
|
PopUpManager.popTip("除草成功");
|
|
}
|
|
(Global.otherPlayerProxy.updateLandData(i, e.data.land), t.callback && t.callback(e.data, i));
|
|
} else TipsUtils.showErrorCodeTips(e.status);
|
|
});
|
|
}
|
|
backToMineScene() {
|
|
const e = 250,
|
|
i = new game.GameScene(!0);
|
|
((i.x = -Const.WIN_W),
|
|
PopUpManager.addSceneUp(i),
|
|
egret.Tween.get(i).to(
|
|
{
|
|
x: 0
|
|
},
|
|
e
|
|
));
|
|
const n = this.viewComponent;
|
|
(egret.Tween.get(n)
|
|
.to(
|
|
{
|
|
x: Const.WIN_W
|
|
},
|
|
e
|
|
)
|
|
.call(function () {
|
|
(this.closeViewComponent(1),
|
|
(this.viewComponent = i),
|
|
game.EventManager.instance.dispatch(SysNotify.FRIEND_REFRESH),
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.SHOW_FRIEND));
|
|
}, this),
|
|
egret.Tween.get(GameLayerManager.instance.popLayer).to(
|
|
{
|
|
x: 0
|
|
},
|
|
e
|
|
));
|
|
}
|
|
showOtherGameScene() {
|
|
const e = 250,
|
|
i = new game.GameScene(!1);
|
|
((i.x = Const.WIN_W),
|
|
PopUpManager.addSceneUp(i),
|
|
egret.Tween.get(i).to(
|
|
{
|
|
x: 0
|
|
},
|
|
e
|
|
));
|
|
let n = this.viewComponent;
|
|
(egret.Tween.get(n)
|
|
.to(
|
|
{
|
|
x: -Const.WIN_W
|
|
},
|
|
e
|
|
)
|
|
.call(function () {
|
|
(game.UIUtils.removeSelf(n),
|
|
(n = null),
|
|
(this.viewComponent = i),
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.HIDE_FRIEND));
|
|
}, this),
|
|
egret.Tween.get(GameLayerManager.instance.popLayer).to(
|
|
{
|
|
x: -Const.WIN_W
|
|
},
|
|
e
|
|
));
|
|
}
|
|
useFertilize(t) {
|
|
const e = GameConfig.SERVER_PATH + "farm/fertilize",
|
|
i = Const.clickLandIndex,
|
|
n = {
|
|
position: i,
|
|
item_id: t.id
|
|
};
|
|
Global.netProxy.sendRequest(e, n, function (e) {
|
|
0 == e.status
|
|
? (PopUpManager.popTip("施肥成功"),
|
|
Global.playerProxy.sellWareHouseItem(t, 1),
|
|
Global.playerProxy.updateLandData(i, e.data))
|
|
: TipsUtils.showErrorCodeTips(e.status);
|
|
});
|
|
}
|
|
kickDisease(t) {
|
|
const e = GameConfig.SERVER_PATH + "farm/disease",
|
|
i = Const.clickLandIndex,
|
|
n = {
|
|
position: i,
|
|
type: t
|
|
};
|
|
Global.netProxy.sendRequest(e, n, function (e) {
|
|
if (0 == e.status)
|
|
(PopUpManager.popTip("操作成功"),
|
|
1 == t
|
|
? Global.playerProxy.sellWareHouseItem(
|
|
{
|
|
id: 108001
|
|
},
|
|
1
|
|
)
|
|
: 2 == t &&
|
|
Global.playerProxy.sellWareHouseItem(
|
|
{
|
|
id: 109001
|
|
},
|
|
1
|
|
),
|
|
Global.playerProxy.updateLandData(i, e.data));
|
|
else {
|
|
if (1012 === e.status)
|
|
return void (1 == t
|
|
? PopUpManager.popTip("除虫剂数量不足")
|
|
: 2 == t && PopUpManager.popTip("除草剂数量不足"));
|
|
TipsUtils.showErrorCodeTips(e.status);
|
|
}
|
|
});
|
|
}
|
|
flushFarm() {
|
|
const t = GameConfig.SERVER_PATH + "farm",
|
|
e = this;
|
|
Global.netProxy.sendRequest(t, {}, function (t) {
|
|
0 == t.status
|
|
? (Global.playerProxy.setPlayerData(t.data),
|
|
Global.playerProxy.setPlayerLandData(t.data),
|
|
e.viewComponent.flushGameScene())
|
|
: TipsUtils.showErrorCodeTips(t.status);
|
|
});
|
|
}
|
|
showViewComponent(e) {
|
|
((this.viewComponent = new game.GameScene(e)),
|
|
(this.viewComponent.mediator = this),
|
|
PopUpManager.addSceneUp(this.viewComponent));
|
|
}
|
|
initUI() {}
|
|
initData() {}
|
|
plantSeed(t, e) {
|
|
const i = GameConfig.SERVER_PATH + "farm/sow-seeds",
|
|
n = {
|
|
position: t,
|
|
item_id: e.id
|
|
};
|
|
return new Promise(function (a, o) {
|
|
Global.netProxy.sendRequest(i, n, function (i) {
|
|
0 == i.status
|
|
? (Global.playerProxy.sellWareHouseItem(e, 1),
|
|
Global.playerProxy.updateLandData(t, i.data),
|
|
TipsUtils.showTipsDownToUp("播种成功"),
|
|
a(i.status))
|
|
: TipsUtils.showErrorCodeTips(i.status);
|
|
});
|
|
});
|
|
}
|
|
shouhuo() {
|
|
const e = Const.clickLandIndex,
|
|
i = {
|
|
position: e
|
|
},
|
|
n = GameConfig.SERVER_PATH + "farm/gather-crop";
|
|
Global.netProxy.sendRequest(n, i, function (i) {
|
|
if (0 === i.status) {
|
|
const n = Global.playerProxy;
|
|
(n.updateWareHouseItem(i.data, i.data.item_add_num),
|
|
n.updateLandData(e, i.data),
|
|
game.EventManager.instance.dispatch(SysNotify.PLANT_REAP, i.data.item_add_num));
|
|
} else TipsUtils.showErrorCodeTips(i.status);
|
|
});
|
|
}
|
|
chanchu() {
|
|
const t = Const.clickLandIndex,
|
|
e = {
|
|
position: t
|
|
},
|
|
i = GameConfig.SERVER_PATH + "farm/clear-land";
|
|
Global.netProxy.sendRequest(i, e, function (e) {
|
|
if (0 === e.status) {
|
|
PopUpManager.popTip("铲除成功");
|
|
const i = Global.playerProxy;
|
|
i.updateLandData(t, e.data);
|
|
} else TipsUtils.showErrorCodeTips(e.status);
|
|
});
|
|
}
|
|
static NAME = "GameMediator";
|
|
};
|
|
((game.GameMediator = GameMediator), __reflect(GameMediator.prototype, "game.GameMediator"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LoginMediator = class LoginMediator extends BaseMediator {
|
|
constructor(t = null) {
|
|
super(LoginMediator.NAME, t);
|
|
this.type = "scene";
|
|
this.isSendReq = !1;
|
|
}
|
|
listNotificationInterests() {
|
|
return [SceneNotify.OPEN_LOGIN, SceneNotify.CLOSE_LOGIN];
|
|
}
|
|
onRegister() {
|
|
(super.onRegister(),
|
|
this.facade.registerMediator(new game.CreateRoleMediator()),
|
|
this.facade.registerMediator(new game.GameMediator()));
|
|
}
|
|
handleNotification(e) {
|
|
e.getBody();
|
|
switch (e.getName()) {
|
|
case SceneNotify.OPEN_LOGIN:
|
|
(this.showViewComponent(),
|
|
window.parent &&
|
|
window.parent.refCode &&
|
|
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_REGIST));
|
|
break;
|
|
case SceneNotify.CLOSE_LOGIN:
|
|
(this.closeViewComponent(1), this.facade.removeMediator(LoginMediator.NAME));
|
|
}
|
|
}
|
|
showViewComponent() {
|
|
this.viewComponent = new game.LoginScene();
|
|
const e = GameLayerManager.gameLayer().sceneLayer;
|
|
e.addChild(this.viewComponent);
|
|
}
|
|
initUI() {}
|
|
initData() {}
|
|
static NAME = "LoginMediator";
|
|
};
|
|
((game.LoginMediator = LoginMediator), __reflect(LoginMediator.prototype, "game.LoginMediator"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const LogoMediator = class LogoMediator extends BaseMediator {
|
|
constructor() {
|
|
super(LogoMediator.NAME);
|
|
this.type = "scene";
|
|
}
|
|
listNotificationInterests() {
|
|
return [SysNotify.START_GAME, SceneNotify.CLOSE_LOADING];
|
|
}
|
|
onRegister() {
|
|
(super.onRegister(),
|
|
this.facade.registerMediator(new game.LoginMediator()),
|
|
this.facade.registerMediator(new game.FindPasswordMediator()));
|
|
}
|
|
showViewComponent() {
|
|
this.viewComponent = new game.LogoScene();
|
|
const e = GameLayerManager.gameLayer().sceneLayer;
|
|
e.addChild(this.viewComponent);
|
|
}
|
|
handleNotification(t) {
|
|
switch (t.getName()) {
|
|
case SysNotify.START_GAME:
|
|
this.showViewComponent();
|
|
break;
|
|
case SceneNotify.CLOSE_LOADING:
|
|
this.closeViewComponent(1);
|
|
}
|
|
}
|
|
static NAME = "LogoMediator";
|
|
};
|
|
((game.LogoMediator = LogoMediator), __reflect(LogoMediator.prototype, "game.LogoMediator"));
|
|
})(game || (game = {}));
|
|
var game;
|
|
!(function (game) {
|
|
const SayMediator = class SayMediator extends BaseMediator {
|
|
constructor() {
|
|
super(SayMediator.NAME);
|
|
}
|
|
listNotificationInterests() {
|
|
return [SceneNotify.OPEN_SAY, SceneNotify.CLOSE_SAY];
|
|
}
|
|
onRegister() {
|
|
super.onRegister();
|
|
}
|
|
showViewComponent() {
|
|
this.viewComponent = new game.SayScene();
|
|
const e = GameLayerManager.gameLayer().sceneLayer;
|
|
e.addChild(this.viewComponent);
|
|
}
|
|
handleNotification(t) {
|
|
switch (t.getName()) {
|
|
case SceneNotify.OPEN_SAY:
|
|
this.showViewComponent();
|
|
break;
|
|
case SceneNotify.CLOSE_SAY:
|
|
this.closeViewComponent(1);
|
|
}
|
|
}
|
|
static NAME = "SayMediator";
|
|
};
|
|
((game.SayMediator = SayMediator), __reflect(SayMediator.prototype, "game.SayMediator"));
|
|
})(game || (game = {}));
|