123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- var t = require;
- var e = module;
- var i = exports;
- var s =
- (this && this.__awaiter) ||
- function (t, n, r, l) {
- return new (r = r || Promise)(function (i, e) {
- function s(t) {
- try {
- a(l.next(t));
- } catch (t) {
- e(t);
- }
- }
- function o(t) {
- try {
- a(l.throw(t));
- } catch (t) {
- e(t);
- }
- }
- function a(t) {
- var e;
- t.done
- ? i(t.value)
- : ((e = t.value) instanceof r
- ? e
- : new r(function (t) {
- t(e);
- })
- ).then(s, o);
- }
- a((l = l.apply(t, n || [])).next());
- });
- };
- Object.defineProperty(i, "__esModule", {value: !0});
- const o = t("App"),
- a = t("GameText"),
- n = t("BaseController"),
- r = t("ViewManager"),
- l = t("QueueExecutor"),
- h = t("ControllerConst"),
- c = t("NotificationConst"),
- d = (t("ViewConst"), t("LayerManager"), t("SoundEffectConst")),
- u = (t("ADController"), t("ADManageBase"), t("BagController")),
- p = t("GuideController"),
- f = t("TipView"),
- g = t("BuffMgr"),
- m = t("GameConst"),
- _ = t("GameModel"),
- y = t("GlobalAttr"),
- v = t("CurrencyService"),
- U = t("MachineService"),
- Z = t("MapService"),
- C = t("GameUIView"),
- b = t("GameView"),
- S = t("HelperCatInfoView"),
- T = t("InviteHelperCatView");
- i.default = class extends n.default {
- constructor() {
- super(),
- (this.gameView = null),
- (this.gameScene = null),
- (this.nextSaveTime = Date.now() + 3e4),
- (this._model = null),
- (this.gameConf = null),
- (this.curViewId = null),
- o.default.ViewManager.register(19, {
- prefabName: "StageUpgradeView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(21, {
- prefabName: "StageUpgradeTipView",
- zIndex: 50,
- controller: this,
- isNotShowLoad: !0,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(20, {
- prefabName: "SwitchMapView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(8, {
- prefabName: "SettingView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(22, {
- prefabName: "AbilityView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- //注册离线收入
- o.default.ViewManager.register(17, {prefabName: "IdleView", zIndex: 100, controller: this, dir: "gameUI"}),
- o.default.ViewManager.register(31, {
- prefabName: "CongratulationView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(38, {
- prefabName: "GameLoadingView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register(54, {
- prefabName: "WorldMapView",
- zIndex: 100,
- controller: this,
- dir: "gameUI"
- }),
- o.default.ViewManager.register1(S.default.VIEW_INFO, this),
- o.default.ViewManager.register1(T.default.VIEW_INFO, this),
- o.default.ViewManager.register1(b.default.VIEW_INFO, this),
- o.default.ViewManager.register1(C.default.VIEW_INFO, this),
- this.setModel(new _.default(this)),
- this.initModuleEvent(),
- this.initProtocolEvents(),
- o.default.NotificationCenter.addListener(c.NotificationConst.INIT_GAME, this.initGame, this, 100);
- }
- destroy() {
- super.destroy();
- }
- initModuleEvent() {
- this.registerFunc(m.GameConst.GET_IDLE, this.getIdle, this),
- this.registerFunc(m.GameConst.ENTER_FB_MAP, this.onEnterFBMap, this),
- this.registerFunc(m.GameConst.EXIT_FB_MAP, this.onExitFBMap, this);
- }
- initProtocolEvents() {
- o.default.NotificationCenter.addListener(r.ViewManagerEvent.VIEW_IS_CLOSE, this.onViewClose, this),
- o.default.NotificationCenter.addListener(c.NotificationConst.ADD_OPEN_VIEW, this.onAddView, this),
- o.default.NotificationCenter.addListener(c.NotificationConst.PLAY_MONEY_ANI, this.onPlayGetMoneyAni, this),
- o.default.NotificationCenter.addListener(c.NotificationConst.MACHINE_UPDATE, this.onUpdateProgress, this),
- o.default.NotificationCenter.addListener(c.NotificationConst.ENTER_MAP, this.onEnterMap, this);
- }
- onUpdateIntegral(t) {}
- initGame() {
- return s(this, void 0, void 0, function* () {
- this._model.init(),
- (this.queueExecutor = new l.QueueExecutor()),
- o.default.Platform.isShowDebugUI() && o.default.ViewManager.open(6),
- o.default.NotificationCenter.removeListener(c.NotificationConst.INIT_GAME, this.initGame, this),
- (this.gameConf = o.default.ConfigManager.gameConf.game),
- (this.gameScene = o.default.SceneManager.getCurrScene()),
- cc.game.on(cc.game.EVENT_HIDE, this.onHide, this),
- cc.game.on(cc.game.EVENT_SHOW, this.onShow, this),
- (g.default.ins = new g.default()),
- o.default.NotificationCenter.dispatch(c.NotificationConst.INIT_GAME_FINISH),
- yield Z.default.ins.loadMap(this._model.getCurMapData().curId),
- o.default.ViewManager.open(4),
- this.registerFunc(m.GameConst.SAVE_DAVE, this.saveToServe, this),
- (this.nextSaveTime = Date.now() + 18e4),
- o.default.TimerManager.doTimer(2e3, 0, this.routine, this),
- o.default.SoundManager.playBg(d.SoundsDefine.BG_GROUND),
- this.checkIdle();
- });
- }
- onHide() {
- return s(this, void 0, void 0, function* () {
- this._model.setIdleTime(), this.saveToServe(), o.default.SoundManager.stopBg(), cc.director.pause();
- });
- }
- onShow() {
- return s(this, void 0, void 0, function* () {
- for (cc.director.resume(), o.default.SoundManager.playBg(d.SoundsDefine.BG_GROUND); ; ) {
- if (
- (o.default.EasyLoading.showLoading(),
- !(300 < Math.abs(o.default.DateUtils.secondNow() - this._model.getCurMapData().startIdleTime)) ||
- (yield o.default.Platform.getServerTime()))
- ) {
- (this.nextSaveTime = Date.now() + 18e4),
- o.default.EasyLoading.hideLoading(),
- o.default.SaveManage.checkIsNeedUpdateData(),
- this.checkIdle(),
- o.default.NotificationCenter.dispatch(c.NotificationConst.ON_SHOW),
- (o.default.GameDataMsr.playerInfo.timestamp = Math.floor(o.default.DateUtils.Now() / 1e3)),
- o.default.AnalyticMgr.activityLogin();
- break;
- }
- yield new Promise(t => {
- o.default.EasyLoading.hideLoading(),
- o.default.ViewManager.open(14, {
- curState: f.TIPSTATE.SURE,
- leftBtnText: a.GameText.getText(17),
- leftFunc: () => {
- setTimeout(() => {
- t();
- }, 100);
- },
- leftThisObj: this,
- title: "提示",
- tipsStr: a.GameText.getText(54)
- });
- });
- }
- });
- }
- routine(t) {
- Date.now() > this.nextSaveTime && this.saveToServe(), o.default.SaveManage.checkIsNeedUpdateData();
- }
- saveToServe() {
- o.default.Platform.saveData(), o.default.AnalyticMgr.activityLogout(), (this.nextSaveTime = Date.now() + 18e4);
- }
- onOpenView(t) {
- switch (t.viewId) {
- case 6:
- break;
- case 4:
- this.onUpdateProgress();
- }
- }
- onViewClose(t) {
- this.curViewId == t && this.queueExecutor.finishFunc();
- }
- onEntreStreet(t) {
- this.queueExecutor.reset();
- }
- onAddView(t, e) {
- this.queueExecutor.regist(() => {
- p.default.isGuide ? this.queueExecutor.finishFunc() : ((this.curViewId = t), e());
- }, this);
- }
- checkIdle() {
-
-
- if (this._model.getCurMapData().startIdleTime) {
- let t = o.default.DateUtils.secondNow() - this._model.getCurMapData().startIdleTime;
- var e;
- t > y.default.ins.offlineRewardMinTime &&
- (t > y.default.ins.offlineRewardMaxTime && (t = y.default.ins.offlineRewardMaxTime),
- (e = v.default.ins.getIdleMoney(t)) && o.default.ViewManager.open(17, t, e));
- }
- }
- getIdle(t, e = !1) {
- return s(this, void 0, void 0, function* () {
- if (e) {
- const e = yield o.default.ControllerManager.applyFunc(h.ControllerConst.AD, 0, 0);
- if (!e || 0 !== e.code) return;
- t *= 2;
- }
- v.default.ins.addMoneyByIdle(t),
- (this._model.getCurMapData().startIdleTime = 0),
- o.default.ViewManager.close(17),
- this.onPlayGetMoneyAni(u.CostType.coin, v.default.ins.getIdleMoney(t));
- });
- }
- onEnterMap() {
- this.onUpdateProgress(), o.default.ViewManager.close(21);
- }
- onEnterFBMap(t) {
- Z.default.ins.loadMap(t || this._model.getFBMapData().curId);
- }
- onExitFBMap(t) {
- Z.default.ins.loadMap(t || this._model.getMainMapData().curId);
- }
- onUpdateProgress() {
- const t = o.default.ViewManager.getView(4);
- t && t.updateProgress(U.default.ins.getMachinProgress());
- }
- onPlayGetMoneyAni(t, e, i) {
- const s = o.default.ViewManager.getView(4);
- s && s.playGetCoinAni(t % 20001, e, i);
- }
- };
|