MainViewPresenter.ts
26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
import { ConfigManager } from "simba-config-manager";
import { GameRecord, PlotManager, ReadonlyPlots, SpecialPlotId } from "../../../avg/AVG";
import { createPresenter, Presenter } from "../../../common/classbase/PresenterBase";
import { View } from "../../../common/classbase/ViewBase";
import { GameTextData } from "../../../common/gameplay/gamedata/GameTextData";
import { UIManager } from "../../../common/gameplay/managers/UIManager";
import { dateSceneConfig } from "../../../config/DateSceneConfig";
import { AutoPopViewType, GuideLocation, GuideOperationType, GuideState, MainTabs, PlotSceneType } from "../../Enums";
import GameDotMgr from "../../GameDotMgr";
import { DatingEventStatus } from "../../model/DatingEventSceneModel";
import { GameModelManager } from "../../model/GameModelManager";
import { HttpRequests } from "../../network/HttpRequests";
import { RegPresenter } from "../PresenterCCViewFactory";
import VerbView from "../VerbView";
import { showToBeContinue } from "../view/impl/AlertToBeContinueImpl";
import { MainView, MainViewProps, MainViewType } from "../view/type/MainView";
import DatingEventViewPresenter from "./DatingEventViewPresenter";
import { DatingScenePresenter } from "./DatingScenePresenter";
import DebugViewPresenter from "./DebugViewPresenter";
import DiscoverViewPresenter from "./DiscoverViewPresenter";
import GuideViewPresenter from "./GuideViewPresenter";
import MessageViewPresenter from "./MessageViewPresenter";
import NoticeViewPresenter from "./NoticeViewPresenter";
import PlotStopViewPresenter from "./PlotStopViewPresenter";
import { AudioManager } from "simba-cc-audio-manager";
import { DeepReadonlyObject } from "simba-utils";
import { ResUtils } from "simba-cc-resutils";
import { GameConstData } from "../../../common/gameplay/gamedata/GameConstData";
import BedroomViewPresenter from "./bedroom/BedroomViewPresenter";
import { UnlockItemModelManager } from "../../model/UnlockItemModelManager";
import { IItemTbl, itemTbl } from "../../../config/ItemTbl";
import { channel, GameConfig } from "../../../GameConfig";
import GameCenter from "../../../cooperation/script/GameCenter";
import { HttpClient } from "simba-httpclient";
import { BedroomCatRewardViewProps } from "../view/type/BedroomCatRewardView";
import BedroomCatRewardViewPresenter from "./bedroom/BedroomCatRewardViewPresenter";
import { BedRoomCatModelManager } from "../../model/BedRoomCatModelManager";
import { PromptAlertDialogViewProps } from "../view/type/PromptAlertDialogView";
import PromptAlertDialogViewPresenter from "./bedroom/PromptAlertDialogViewPresenter";
import { UnlockSpecialPlotModelManager } from "../../model/UnlockSpecialPlotModelManager";
import { DateType, PageIndex } from "../../../avg/EditorEnums";
import NewNoticeViewPresenter from "./notice/NewNoticeViewPresenter";
import { SourceView } from "../view/type/notice/NewNoticeView";
import ExtraPlotViewPresenter from "./ExtraPlotViewPresenter";
import UrgentNoticeViewPresenter from "./notice/UrgentNoticeViewPresenter";
import { SDK } from "simba-sdk";
const TabPresenterFactory: ({ new(): Presenter } & { uuid: string })[] = [
MessageViewPresenter,
DatingEventViewPresenter,
BedroomViewPresenter,
DiscoverViewPresenter
];
/**主线剧情的下标 */
const MAIN_PLOT_INDEX: number = 0;
@RegPresenter(MainViewType)
export default class MainViewPresenter extends Presenter<undefined, MainView> {
static uuid = "MainViewPresenter";
private _subPresenters: Presenter<any, View>[] = [];
private _currentTab = 0;
private _viewProps: MainViewProps;
private _loadingTab = false;
private readonly _tabToggleDelayTime = 618;
private _tabClickAble: boolean = false;
private _itemId: number = -1;
private _hasItem: boolean = false;
public static tabIndex: number = -1;
constructor() {
super();
this._viewProps = {
selectedTab: 0,
messageRedDot: false,
datingEventRedDot: false,
waitRedDot: false,
discoverRedDot: false,
onTabClick: this.onTabClick,
onDebugClick: this.onDebugClickCallback,
onUrgentNoticeClick: this.onUrgentNoticeClickCallback,
onGoToShopClick: this.onGoToShopClickCallback,
onCommonProblemClick: this.onCommonProblemClickCallback,
onRewardBtnClickCallback: this.onRewardBtnClickCallback,
};
}
onDebugClickCallback = () => {
UIManager.pushPresenter(DebugViewPresenter, undefined);
}
onUrgentNoticeClickCallback = () => {
UIManager.pushPresenter(UrgentNoticeViewPresenter, undefined);
}
onGoToShopClickCallback = () => {
GameDotMgr.getInstance().dotClickUI("shop_btn_MainView");
if (channel == "wechat") {
// GameCenter.getInstance().openSubProgram(GameConfig.youZanShopAppId);
let link = GameModelManager.getYouZanShopUrlByType(8);
if (link) {
SDK.openProgramV2(GameConfig.youZanShopAppId, link);
}
} else if (channel == "android") {
let link = GameModelManager.getTaoBaoShopUrlByType(8);
if (link) {
GameModelManager.jumpToTaobaoShop(link);
}
} else {
UIManager.showToast("该功能在当前平台不可使用");
}
}
onCommonProblemClickCallback = async () => {
try {
let resStr = await new HttpClient(GameConfig.commonProblemConfigUrl).get() as string;
let res = JSON.parse(resStr);
if (res) {
UIManager.pushPresenter(NoticeViewPresenter, {
title: res.title,
content: res.content
});
}
} catch (error) {
console.error(error);
}
}
onRewardBtnClickCallback = () => {
let temp: BedroomCatRewardViewProps = {
onClickTabbarBtn: () => { },
onCloseBtnClick: () => { },
};
UIManager.pushPresenter(BedroomCatRewardViewPresenter, temp);
}
checkRedDot = (plots: ReadonlyPlots) => {
this._viewProps.messageRedDot = plots[MAIN_PLOT_INDEX].plotSceneType === PlotSceneType.Message || plots[MAIN_PLOT_INDEX].plotSceneType === PlotSceneType.PhoneCall;
this._viewProps.datingEventRedDot = false;
this._viewProps.datingEventRedDot = plots && (plots[0].plotSceneType === PlotSceneType.DatingEvent && (plots[0].id !== SpecialPlotId.ToBeContinued && plots[0].id !== SpecialPlotId.End));
this.view.setProps(this._viewProps);
if (plots[MAIN_PLOT_INDEX] && plots[MAIN_PLOT_INDEX].plotSceneType === PlotSceneType.BlockPlot) {
GameModelManager.dealBlockedPlot();
} else {
let change = GameModelManager.isChangePlotSceneType();
if (change) {
let p = plots[MAIN_PLOT_INDEX];
let isSpecial = p.id === SpecialPlotId.End || p.id === SpecialPlotId.ToBeContinued;
if (!isSpecial) {
this.onMainPlotChanged(p.plotSceneType, p.plotSceneTypeId);
GameModelManager.setIsChangePlotSceneType(false);
}
}
}
}
onRefreshDiscoveryRedDot = () => {
this._viewProps.discoverRedDot = !GameModelManager.checkResumeFullEnergyMarked();
this.view.setProps(this._viewProps);
}
async start() { // 开始游戏
this._subPresenters[0] = await createPresenter(TabPresenterFactory[0]);
MainViewPresenter.tabIndex = 0;
let viewContainer = this._view.getTabContentContainer();
this._subPresenters[0].open(viewContainer, undefined);
this.dealTabGuide(MainTabs.messageTab);
this._viewProps.selectedTab = MainTabs.messageTab;
this._disposable.add(GameModelManager.RefreshDiscoverTabRed.on(this.onRefreshDiscoveryRedDot));
this._disposable.add(GameModelManager.ShowPlotBlocked.on(this.onShowPlotBlocked));
this._disposable.add(GameModelManager.MainTabForceClick.on(this.onMainTabForceClick));
// this._disposable.add(GameModelManager.CheckMainTabGuide.on(this.checkTabGuide));
this._disposable.add(GameModelManager.AutoPopView.on(this.onAutoPopView));
this._disposable.add(GameModelManager.UnlockItem.on(this.onUnlockItem));
this._disposable.add(GameModelManager.BedroomViewBack.on(this.onBedroomViewBack));
this._disposable.add(GameModelManager.RefreshAllStatus.on(this.onRefreshAllStatus));
this._disposable.add(GameModelManager.JumpToViewInGame.on(this.onJumpToViewInGame));
this.checkRedDot(PlotManager.getCurrentPlots());
PlotManager.PlotStartEvent.on(this.checkRedDot);
let needEnterSpecialDatingScene = this.checkIsNeedToEnterSpecialDatingScene();
// check tab guide
// this.checkTabGuide();
if (needEnterSpecialDatingScene) {
GameConfig.isVerb = true;
this.enterSpecialEventScene();
this._currentTab = MainTabs.datingEventTab;
this._viewProps.selectedTab = MainTabs.datingEventTab;
}
this._tabClickAble = true;
GameModelManager.dealAutoResumeFullEnergy();
//进入主界面更新红点状态
this.view.updateBedRoomRedDot();
this.updateRewardBtnRedDot();
setTimeout(() => {
//关闭等待界面
this.view.showWaitingView(false);
//开始弹起自动窗口
if (PlotManager.getCurrentPlots()[MAIN_PLOT_INDEX].id === SpecialPlotId.ToBeContinued) {
GameModelManager.registerAutoPopView(AutoPopViewType.ToBeContinued);
} else if (this.checkNoviceTutorialOver()) {
// GameModelManager.registerAutoPopView(AutoPopViewType.Notice);
}
let autoShowNotice = GameModelManager.getAutoShowNotice();
if (autoShowNotice) {
GameModelManager.registerAutoPopView(AutoPopViewType.Notice);
}
// GameModelManager.registerAutoPopView(AutoPopViewType.RewardView);
let unlockItems = UnlockItemModelManager.unlockItems;
if (unlockItems.indexOf(4) == -1) {
GameModelManager.registerAutoPopView(AutoPopViewType.NoteBook);
}
// let autoShowUrgentNotice = GameModelManager.getUrgentNoticeInfo().autoShow;
// if (autoShowUrgentNotice) {
// GameModelManager.registerAutoPopView(AutoPopViewType.UrgentNotice);
// }
if (!needEnterSpecialDatingScene) {
let hasGuide = GameModelManager.checkHasGuide();
if (!hasGuide) {
GameModelManager.checkAutoPopView();
}
}
}, 2000);
}
/**
* 检查新手教程是否完成,当前新手教程完成的判定是完成第一章
* @returns
*/
checkNoviceTutorialOver(): boolean {
let models = GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
if (models[i].status == 4) {
return true;
}
}
return false;
}
async enterSpecialEventScene() {
let arr = GameModelManager.getMainDatingEventScenesModel();
UIManager.pushPresenter(DatingScenePresenter, arr[0], true);
}
checkIsNeedToEnterSpecialDatingScene() {
let arr = GameModelManager.getMainDatingEventScenesModel();
let need = arr && arr.length === 1 && arr[0].status !== DatingEventStatus.Completed;
return need;
}
onMainTabForceClick = (param: { index: number, pureClick: boolean, propId?: number }) => {
UIManager.popToPresenter(this);
let index = param.index;
this.onTabClick(index);
}
onClose() {
super.onClose();
UIManager.popToPresenter(this);
}
onOpen() {
super.onOpen(undefined);
// this.perloadPrefab();
// this.discoverInit();
}
discoverInit() {
GameRecord.onGlobalVariableChange("red_pot_" + DiscoverViewPresenter.uuid, () => {
this._viewProps.discoverRedDot = GameModelManager.checkRedPot(DiscoverViewPresenter.uuid);
this.view.setProps(this._viewProps);
});
this._viewProps.discoverRedDot = GameModelManager.checkRedPot(DiscoverViewPresenter.uuid);
this.view.setProps(this._viewProps);
}
perloadPrefab() {
let PFList = ["prefab/ui/DatingEventView"];
cc.resources.preload(PFList);
}
onEnterBackground() {
super.onEnterBackground();
this.view.updateBedRoomRedDot();//更新卧室界面红点
this.updateRewardBtnRedDot();
if (this._subPresenters[this._currentTab])
this._subPresenters[this._currentTab].onEnterBackground();
}
/**presenter进入前景 */
async onEnterForeground() {
super.onEnterForeground();
if (this._subPresenters[this._currentTab]) {
this._subPresenters[this._currentTab].onEnterForeground();
this._subPresenters[this._currentTab].onEnterForeground();
}
if (PlotManager.getCurrentPlots()[MAIN_PLOT_INDEX].id === SpecialPlotId.ToBeContinued) {
GameModelManager.registerAutoPopView(AutoPopViewType.ToBeContinued);
}
if (!GameConfig.isVerb) {
GameModelManager.checkAutoPopView();
}
this.view.updateBedRoomRedDot();//更新卧室界面红点
this.updateRewardBtnRedDot();
}
onShow() {
super.onShow();
// this.checkTabGuide();
}
onTabClick = async (index: number, callback?: Function, isDot?: Boolean) => {
if (!this._tabClickAble) {
return;
}
// if (isDot != false) {
// let uiName = ["click_message", "click_event", "click_wait", "click_finding"];
// GameDotMgr.getInstance().dotClickUI(uiName[index]);
// }
this.view.updateBedRoomRedDot();//更新卧室界面红点
this.updateRewardBtnRedDot();
this._view.showRewardBtn(index !== MainTabs.bedroomTab);
this._view.showBottonsNode(index !== MainTabs.bedroomTab);
this._view.showSubGameNode(index !== MainTabs.bedroomTab);
this.dealTabGuide(index);
let uuid = TabPresenterFactory[index].uuid;
if (!GameModelManager.checkFuncUnloced(uuid)) {
UIManager.showToast(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MAIN_FUNCTION_NOT_OPEN));
return;
}
if (this._loadingTab) return;
if (this._currentTab !== index) {
if (this._subPresenters[this._currentTab])
this._subPresenters[this._currentTab].view.hide();
this._currentTab = index;
this._viewProps.selectedTab = index;
this._view.setProps(this._viewProps);
if (index !== 2) {
MainViewPresenter.tabIndex = index;
}
if (!this._subPresenters[this._currentTab]) {
this._loadingTab = true;
await createPresenter(TabPresenterFactory[this._currentTab]).then((presenter) => {
this._subPresenters[this._currentTab] = presenter;
presenter.open(this.view.getTabContentContainer(), undefined);
setTimeout(() => {//延时等待618毫秒,View 中UI刷新
this._loadingTab = false;
}, this._tabToggleDelayTime);
if (callback) {
callback();
}
this._view.showTabBar(index !== MainTabs.bedroomTab);
});
} else {
if (this._subPresenters[this._currentTab]) {
this._subPresenters[this._currentTab].view.show();
}
if (callback) {
callback();
}
this._view.showTabBar(index !== MainTabs.bedroomTab);
}
} else {
if (callback) {
callback();
}
}
}
dealTabGuide(index: number) {
let r = GameRecord.globalVariables["guide_main_tab" + index] as number;
r = r === undefined ? GuideState.close : r;
if (r === GuideState.Open) {
GameModelManager.setGuideMainTabRecord(index, GuideState.Complete);
}
}
checkTabGuide = () => {
let check: boolean = false;
if (!check) {
return;
}
let index = GameModelManager.getMainTabGuideIndex();
if (index !== -1) {
//attention
let redDotArr = [this._viewProps.messageRedDot, this._viewProps.datingEventRedDot, this._viewProps.waitRedDot, this._viewProps.discoverRedDot];
if (!redDotArr[index] || this._currentTab === index) {
return;
}
UIManager.popToPresenter(this);
let m = this.view.getGuideTabParam(index);
if (m) {
let location: GuideLocation = index === MainTabs.datingEventTab ? GuideLocation.TabDate : GuideLocation.TabMsg;
m.call = () => {
this.onTabClick(index);
this.view.hideClickAniByIndex(index);
GameDotMgr.getInstance().dotGuide(GuideOperationType.Click, location);
}
UIManager.pushPresenter(GuideViewPresenter, m);
GameDotMgr.getInstance().dotGuide(GuideOperationType.Show, location);
}
}
}
switchTab(tabIndex: number) {
if (this._currentTab != tabIndex) {
let prevIndex = this._currentTab;
this._currentTab = tabIndex;
this._viewProps.selectedTab = this._currentTab;
this._view.setProps(this._viewProps);
}
}
onAutoPopView = async (viewType: AutoPopViewType) => {
switch (viewType) {
case AutoPopViewType.ToBeContinued:
{
await showToBeContinue();
}
break;
case AutoPopViewType.Notice:
{
UIManager.pushPresenter(NewNoticeViewPresenter, SourceView.MessageView);
}
break;
case AutoPopViewType.RewardView:
{
await this.onRewardBtnClickCallback();
}
break;
case AutoPopViewType.NoteBook:
{
let temp: PromptAlertDialogViewProps = {
iconSpritePath: GameConstData.GAME_CONST_BEDROOMCAT_ITEM_SPR_DIR + 4,
contentLabel: "恭喜您获得新物品:日记本,快去卧室查看吧!",
};
UIManager.pushPresenter(PromptAlertDialogViewPresenter, temp);
setTimeout(() => {
UnlockItemModelManager.saveItemIdToGameRecord(4);
UnlockSpecialPlotModelManager.saveUnlockedSpecialPlotIdByItemIdToGameRecord(5);
}, 3000);
}
break;
case AutoPopViewType.UrgentNotice:
{
UIManager.pushPresenter(UrgentNoticeViewPresenter, undefined);
}
break;
case AutoPopViewType.PlotStop:
{
UIManager.pushPresenter(PlotStopViewPresenter, undefined);
}
break;
}
}
onShowPlotBlocked = () => {
let plotId: number = GameModelManager.getCurPlotBlockedId();
// GameDotMgr.getInstance().dotExposure(StringUtils.format(ExposureType.Plotblock, plotId));
GameModelManager.registerAutoPopView(AutoPopViewType.PlotStop);
}
onMainPlotChanged = async (pType: PlotSceneType, pId: number) => {
if (!GameModelManager.isMainPlotSceneType() || ConfigManager.getConfig(dateSceneConfig, pId).DateType == DateType.Date_Sp) {
return;
}
UIManager.popToPresenter(this);
let comp = cc.director.getScene().getChildByName("Canvas").getChildByName("VerbRoot").getChildByName("VerbView").getComponent(VerbView);
if (this._hasItem && -1 !== this._itemId) {
//加载图和组织物品掉落数据
let showItemCfg: DeepReadonlyObject<IItemTbl> | undefined = undefined;
let itemSpriteFrame: cc.SpriteFrame | undefined = undefined;
showItemCfg = this.getShowItemCfg(this._itemId);
if (showItemCfg) {
let path: string = GameConstData.GAME_CONST_ITEM_BIG_SPR_DIR + showItemCfg.icon;
itemSpriteFrame = await ResUtils.loadRes(path, cc.SpriteFrame);
comp.setItemDropData(itemSpriteFrame, showItemCfg);
this._itemId = -1;
this._hasItem = false;
}
}
switch (pType) {
case PlotSceneType.Message:
{
this.onTabClick(MainTabs.messageTab, () => {
this._subPresenters[this._currentTab].onShow();
comp.toChat({ title: "", desc: "来电了!!" });
setTimeout(() => {
GameModelManager.ForceClickDataReady.emit();
GameModelManager.ForceClickMsgItem.emit(pId);
}, 500);
});
}
break;
case PlotSceneType.DatingEvent:
{
let cfgs = ConfigManager.getAllConfig(dateSceneConfig);
let ids: string[] = [];
for (const id in cfgs) {
if (cfgs[id].DateType == DateType.Date_Normal) {
ids.push(id);
}
}
let plotIds: number[] = [];
let models = GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
plotIds.push(models[i].id);
}
let index = plotIds.indexOf(pId);
let title = "第" + (plotIds.length) + "章:";
let cfg = ConfigManager.getConfig(dateSceneConfig, pId);
let desc = cfg && cfg.name ? GameModelManager.getConfigLanguageTxt(cfg.name) : "";
comp.toDating(() => {
AudioManager.playEffect('verb');
this.onTabClick(MainTabs.datingEventTab, () => {
GameModelManager.ForceClickDataReady.emit();
GameModelManager.ForceClickDatingItem.emit(pId);
})
this.view.hideClickAniByIndex(MainTabs.datingEventTab);
}, { title: title, desc: desc })
}
break;
}
}
getShowItemCfg(itemId: number): DeepReadonlyObject<IItemTbl> | undefined {
let cfg: DeepReadonlyObject<IItemTbl> | undefined = undefined;
if (itemId) {
cfg = ConfigManager.getConfig(itemTbl, itemId);
}
return cfg;
}
onUnlockItem = (itemId: number) => {
let unlockItems = UnlockItemModelManager.unlockItems;
let isNew = unlockItems.indexOf(itemId) == -1;
if (isNew) {
this._itemId = itemId;
this._hasItem = true;
//写存档+组织数据并派发
UnlockItemModelManager.saveItemIdToGameRecord(itemId);
}
}
/**
* 卧室返回点击UI事件
* @param index 返回具体tabIndex
*/
onBedroomViewBack = (index: number) => {
this._view.onTabButtonClick(null, `${index}`);
}
onRefreshAllStatus = async () => {
this.checkRedDot(PlotManager.getCurrentPlots());
GameConfig.showToBeContinue = false;
let needEnterSpecialDatingScene = this.checkIsNeedToEnterSpecialDatingScene();
// check tab guide
// this.checkTabGuide();
if (needEnterSpecialDatingScene) {
GameConfig.isVerb = true;
this.enterSpecialEventScene();
this._currentTab = MainTabs.datingEventTab;
this._viewProps.selectedTab = MainTabs.datingEventTab;
} else {
let hasGuide = GameModelManager.checkHasGuide();
if (!hasGuide) {
GameModelManager.checkAutoPopView();
}
}
this._tabClickAble = true;
GameModelManager.dealAutoResumeFullEnergy();
//进入主界面更新红点状态
this.view.updateBedRoomRedDot();
this.updateRewardBtnRedDot();
}
updateRewardBtnRedDot() {
for (let i = 1; i < 4; i++) {
let catRewardStatus = BedRoomCatModelManager.getCatRewardStatus(i);
for (let j = 0; j < catRewardStatus.length; j++) {
if (catRewardStatus[j] == 1) {
this.view.getRewardRedDotNode().active = true;
return;
} else {
this.view.getRewardRedDotNode().active = false;
}
}
}
}
/**
* 卧室返回点击UI事件
* @param index 返回具体tabIndex
*/
onJumpToViewInGame = (index: PageIndex) => {
let tab = MainTabs.messageTab;
switch (index) {
case PageIndex.MessageView:
tab = MainTabs.messageTab
this._view.onTabButtonClick(null, `${tab}`);
break;
case PageIndex.DateEventView:
tab = MainTabs.datingEventTab
this._view.onTabButtonClick(null, `${tab}`);
break;
case PageIndex.BedroomView:
tab = MainTabs.bedroomTab
this._view.onTabButtonClick(null, `${tab}`);
break;
case PageIndex.ExtraPlotView:
tab = MainTabs.datingEventTab
this._view.onTabButtonClick(null, `${tab}`);
UIManager.pushPresenter(ExtraPlotViewPresenter, undefined);
break;
default:
console.error("The pageIndex is invalid.");
UIManager.showToast("无效的页面跳转");
break;
}
}
}