52f06191-b63c-4fbb-9df6-1c1bbda46344.js
35.3 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
628
629
630
631
632
"use strict";
cc._RF.push(module, '52f06GRtjxPu532HBu9pGNE', 'DatingScenePresenter');
// script/game/ui/presenter/DatingScenePresenter.ts
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatingScenePresenter = void 0;
const simba_cc_audio_manager_1 = require("simba-cc-audio-manager");
const simba_config_manager_1 = require("simba-config-manager");
const simba_utils_1 = require("simba-utils");
const AVG_1 = require("../../../avg/AVG");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const EditorEvents_1 = require("../../../avg/EditorEvents");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameConstData_1 = require("../../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const DateSceneConfig_1 = require("../../../config/DateSceneConfig");
const Enums_1 = require("../../Enums");
const CDKeyEventManager_1 = require("../../model/CDKeyEventManager");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const GameModelManager_1 = require("../../model/GameModelManager");
const ChapterBtn_1 = require("../ChapterBtn");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const VerbView_1 = require("../VerbView");
const DatingSceneView_1 = require("../view/type/DatingSceneView");
const AlertDialogViewPresenter_1 = require("./AlertDialogViewPresenter");
const ReviewPlotViewPresenter_1 = require("./ReviewPlotViewPresenter");
const SentenceSelectorViewPresenter_1 = require("./SentenceSelectorViewPresenter");
let DatingScenePresenter = /** @class */ (() => {
let DatingScenePresenter = class DatingScenePresenter extends PresenterBase_1.Presenter {
constructor() {
super(...arguments);
this._executingPlot = false;
this._completingPlot = false;
this._showScrollView = false;
/**是否时回忆 */
this._isReview = false;
// private _actionFilter?: (action: DeepReadonly<Action>) => boolean;
this._plotBranch = 0;
/**出现选择时记录当前选择的id*/
this._currSelect = undefined;
/**本次约会剧情是否结束 */
this._finished = false;
//dating scene which id is 1, need to deal by specially;
this._specialDealSceneId = 1;
this._isDotTutorial = false;
this._showBackBtn = true;
this._reviewPlot = "";
/**完成当前剧情回调 */
this.completePlot = async () => {
if (this._executingPlot || this._completingPlot || !this._currPlot || this._finished)
return;
let content = this._currPlot.sentences[0].content;
if (content && content.type === AVG_1.SentenceType.SELECT && this._currSelect === undefined)
return;
this._completingPlot = true;
// GameModelManager.pushDateSceneKeyPlot(this._model.id, this._currPlot.id);
if (this._model.isExtra) {
GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
}
else {
GameModelManager_1.GameModelManager.setIsMainPlotSceneType(true);
}
if (this._isReview) {
let nextPlot = await AVG_1.PlotManager.getNextPlot(this._currPlot, this._currSelect);
if (nextPlot) {
this._currPlot = nextPlot;
}
}
else {
this._model.status = DatingEventSceneModel_1.DatingEventStatus.InProgress;
if (this._isDotTutorial) {
let session = this._model.config.id;
if (content && content.type === AVG_1.SentenceType.SELECT) {
// GameDotMgr.getInstance().dotTutorial(TutorialType.Event, TutorialState.SelectSentenceRet, { session: session, plotId: this._currPlot.id, select: this._currSelect })
}
GameModelManager_1.GameModelManager.dotPlotProgress();
}
let nextPlots = await AVG_1.PlotManager.completePlot(this._currPlot, this._currSelect);
this._currPlot = nextPlots[this._plotBranch];
}
this._currSelect = undefined;
this._completingPlot = false;
this.execPlot();
};
this.onRollBackBtnCallback = () => {
this._showScrollView = !this._showScrollView;
this.view.getScrollViewRootNode().active = this._showScrollView;
if (this._showScrollView) {
let scrollView = this.view.getScrollViewRootNode().getChildByName("ScrollView");
scrollView.scaleY = 0;
cc.tween(scrollView)
.to(0.3, { scaleY: 1 })
.start();
this.CreateOrUpdateChapterBtns();
}
else {
this.view.getScrollViewContentNode().removeAllChildren();
}
};
this.onClickRollBackBtn = (pid) => {
CDKeyEventManager_1.default.getInstance().shiftCDKeyRemovePlotAD();
let removeAdCardNum = CDKeyEventManager_1.default.getInstance().checkCDKeyRemovePlotAD();
let temp = {
dataptr: {},
titlecontent: "此功能不可逆",
content: "使用传送门会清掉此章节到已解锁最新章节之间的剧情存档和剧情内产生的数值,<color=red>且不可逆</color>,确定使用传送门吗?",
ishasad: !(removeAdCardNum > 0),
istwobtn: true,
adconfig: "inject_fruit",
hasBanner: false,
callback: async (type, ret) => {
if (ret) {
let retainVar = this.getRetainVarKeyArr();
await AVG_1.PlotManager.rollbackToPlot(pid, false, retainVar);
this.rollBackDateAdArray(pid);
AVG_1.GameRecord.saveRecord();
// this.rollBackPlotInfo(pid);
this.view.getScrollViewContentNode().removeAllChildren();
this._showScrollView = !this._showScrollView;
this.view.getScrollViewRootNode().active = this._showScrollView;
this.view.closeView();
await GameModelManager_1.GameModelManager.init((value) => {
});
GameModelManager_1.GameModelManager.setIsChangePlotSceneType(true);
UIManager_1.UIManager.showSceneToast("数据刷新完成");
let isSpecialScene = this._model.id === this._specialDealSceneId;
this._showBackBtn = !(isSpecialScene && this._model.status === DatingEventSceneModel_1.DatingEventStatus.InProgress);
this.view.showBackBtn(this._showBackBtn);
GameModelManager_1.GameModelManager.RefreshAllStatus.emit();
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
};
this.onDeadEvent = (pid) => {
if (this._model.status == DatingEventSceneModel_1.DatingEventStatus.Completed) {
let temp = {
dataptr: {},
titlecontent: "提示",
content: "触发了死亡结局,但因为是在回忆模式,所以章节不会被重置",
ishasad: false,
istwobtn: false,
adconfig: "",
hasBanner: false,
callback: async (type, ret) => {
if (ret) {
this.view.closeView();
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
}
else {
let temp = {
dataptr: {},
titlecontent: "提示",
content: "触发了死亡结局,本章节将<color=red>重置</color>!!",
ishasad: false,
istwobtn: false,
adconfig: "",
hasBanner: false,
callback: async (type, ret) => {
if (ret) {
let retainVar = this.getRetainVarKeyArr();
await AVG_1.PlotManager.rollbackToPlot(pid, false, retainVar);
this.rollBackDateAdArray(pid);
AVG_1.GameRecord.saveRecord();
// this.rollBackPlotInfo(pid);
this.view.getScrollViewContentNode().removeAllChildren();
this._showScrollView = !this._showScrollView;
this.view.getScrollViewRootNode().active = this._showScrollView;
this.view.closeView();
await GameModelManager_1.GameModelManager.init((value) => {
});
GameModelManager_1.GameModelManager.setIsChangePlotSceneType(true);
UIManager_1.UIManager.showSceneToast("数据刷新完成");
let isSpecialScene = this._model.id === this._specialDealSceneId;
this._showBackBtn = !(isSpecialScene && this._model.status === DatingEventSceneModel_1.DatingEventStatus.InProgress);
this.view.showBackBtn(this._showBackBtn);
GameModelManager_1.GameModelManager.RefreshAllStatus.emit();
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
}
};
this.filterFunc = (action) => {
var _a, _b;
let isExcute = true;
if (action.type === AVG_1.ActionType.ModifyVariable) {
isExcute = !GameModelManager_1.GameModelManager.checkPlotTipAddGraceAlready((_a = this._currPlot) === null || _a === void 0 ? void 0 : _a.id);
if (isExcute) {
GameModelManager_1.GameModelManager.pushTipAddGracePlot((_b = this._currPlot) === null || _b === void 0 ? void 0 : _b.id);
}
}
return isExcute;
};
this.onReviewButtonClickCallback = async () => {
let temp = {
isReview: this._isReview,
plotString: this._reviewPlot,
startPlotId: this._model.config.start_plot_id,
currentPlotId: this._currPlot.id,
};
UIManager_1.UIManager.pushPresenter(ReviewPlotViewPresenter_1.default, temp);
};
this.onSpecialToast = (type) => {
UIManager_1.UIManager.showSpecialToast(type);
};
}
onOpen(param) {
super.onOpen(param);
this._finished = false;
this._isDotTutorial = false;
this._reviewPlot = "";
this.view.completePlotCallback = this.completePlot;
this.view.onRollBackBtnCallback = this.onRollBackBtnCallback;
this.view.onReviewButtonClickCallback = this.onReviewButtonClickCallback;
this._model = param;
if (this._model.status === DatingEventSceneModel_1.DatingEventStatus.New) {
this._model.status = DatingEventSceneModel_1.DatingEventStatus.InProgress;
}
let isSpecialScene = this._model.id === this._specialDealSceneId;
// deal special :hide backBtn
this._showBackBtn = !(isSpecialScene && this._model.status === DatingEventSceneModel_1.DatingEventStatus.InProgress);
this.view.showBackBtn(this._showBackBtn);
// this.view.setRunCloseAction((isSpecialScene && this._model.status !== DatingEventStatus.Completed));
if (this._model.isExtra) {
GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
this.view.showRollBackBtn(false);
}
else {
GameModelManager_1.GameModelManager.setIsMainPlotSceneType(true);
this.view.showRollBackBtn(true);
}
simba_utils_1.delay(0.1).then(async () => {
if (param.status === DatingEventSceneModel_1.DatingEventStatus.Completed) {
this._isReview = true;
// this._actionFilter = (action) => {
// return action.type !== ActionType.ModifyVariable;
// }
this._model.background = "";
this._currPlot = this._model.firstPlot;
}
else {
this._isReview = false;
if (this._model.isExtra) {
GameModelManager_1.GameModelManager.setBranchInProgress(this._model.id);
}
let plots = AVG_1.PlotManager.getCurrentPlots();
this._plotBranch = plots.findIndex(v => v.plotSceneType === Enums_1.PlotSceneType.DatingEvent && v.plotSceneTypeId === param.id);
this._isDotTutorial = GameModelManager_1.GameModelManager.checkIsDotTutorial() && this._plotBranch === 0;
this._currPlot = plots[this._plotBranch];
if (this._currPlot.id === this._model.firstPlot.id) {
AVG_1.GameRecord.recordVariables.bgm = ""; // 新约会,不继承之前剧情的背景音乐存档
this._model.background = "";
}
this._currSelect = AVG_1.PlotManager.getPlotSelection(this._currPlot.id);
// if(!this._currSelect) this._currSelect = 0;
if (AVG_1.GameRecord.recordVariables.bgm) {
simba_cc_audio_manager_1.AudioManager.playMusic(AVG_1.GameRecord.recordVariables.bgm);
}
//dot main plot start
if (0 === this._plotBranch && this._currPlot && this._currPlot.id === this._model.firstPlot.id) {
GameModelManager_1.GameModelManager.dotMainLinePlotStart();
}
}
if (this._model.background) {
await this.view.setBackground("textures/background/dating_event/" + this._model.background);
}
this.execPlot();
});
this._disposable.add(EditorEvents_1.EditorEvents.SET_DATING_BG.on((bgPath) => {
this._model.background = bgPath;
if (bgPath)
bgPath = "textures/background/dating_event/" + bgPath;
return this.view.setBackground(bgPath);
}));
this._disposable.add(EditorEvents_1.EditorEvents.SET_DATING_BG_EFFECT.on((bgPath) => {
this._model.background = bgPath;
if (bgPath)
bgPath = "textures/background/dating_event/" + bgPath;
return this.view.setBackgroundEffect(bgPath);
}));
this._disposable.add(GameModelManager_1.GameModelManager.RollBackToPlot.on(this.onClickRollBackBtn));
this._showScrollView = false;
this.view.getScrollViewRootNode().active = this._showScrollView;
this._disposable.add(GameModelManager_1.GameModelManager.DeadEvent.on(this.onDeadEvent));
this._disposable.add(GameModelManager_1.GameModelManager.SpecialToast.on(this.onSpecialToast));
}
onClose() {
super.onClose();
this._currPlot = undefined;
simba_cc_audio_manager_1.AudioManager.stopMusic();
// UIManager.popToPresenter(this);
if (!this._model.isExtra) {
GameModelManager_1.GameModelManager.CloseDatingSceneView.emit(this._model.id);
}
}
async execPlot() {
if (this._currPlot) {
if (this._currPlot.sentences && this._currPlot.plotSceneType === Enums_1.PlotSceneType.DatingEvent && this._currPlot.plotSceneTypeId === this._model.id) {
this._executingPlot = true;
const sentence = this._currPlot.sentences[0];
const content = sentence.content;
const roleData = GameModelManager_1.GameModelManager.getRoleData(sentence.roleId);
let otherPortrait = undefined;
let isShowRouge = this.checkIsShowRouge(this._currPlot.id);
if (this._currPlot.portrait !== undefined) {
let otherRole = GameModelManager_1.GameModelManager.getRoleData(this._currPlot.portrait);
if (otherRole) {
// otherPortrait = otherRole.getPortrait(this._currPlot.portraitFace);
otherPortrait = this.getPortraitByRole(otherRole, this._currPlot.portraitFace);
}
}
if (content) { // TODO 图片设置
if (content.type === AVG_1.SentenceType.TEXT) {
this.view.showBackBtn(this._showBackBtn);
if (this._model.isExtra) {
this.view.showRollBackBtn(false);
}
else {
this.view.showRollBackBtn(true);
}
await this.view.setContent(sentence.roleId === GameConstData_1.GameConstData.GAME_CONST_PLAYER_ROLE_VALUE, AVG_1.richNodesToCocosString(content.value), sentence.roleId === 1 ? "" : roleData.getNameIcon(), sentence.roleId === 1 ? undefined : roleData.getConfig().name,
// sentence.roleId === 1 ? otherPortrait : roleData.getPortrait(this._currPlot.face,),
sentence.roleId === 1 ? otherPortrait : this.getPortraitByRole(roleData, this._currPlot.face), otherPortrait, isShowRouge);
let plotName = "<color=#EFDA91>" + (sentence.roleId === 1 ? "旁白" : roleData.getConfig().name) + ":</c>\n";
let plotContent = AVG_1.richNodesToCocosString(content.value) + "\n";
if (this._isReview) {
this._reviewPlot = this._reviewPlot + plotName;
this._reviewPlot = this._reviewPlot + plotContent;
}
}
else if (content.type === AVG_1.SentenceType.SELECT) {
this.view.showBackBtn(false);
this.view.showRollBackBtn(false);
let setSelection = async () => {
let value = content.value[this._currSelect];
let str = value.summary;
this._reviewPlot = this._reviewPlot + "<color=#D36777>" + "选项" + ":</c>\n";
if (value.content && value.content.type === AVG_1.SentenceType.EMPTY) { // 空类型,不做展示
await this.completePlot();
if (this._isReview) {
this._reviewPlot = this._reviewPlot + str + "\n";
}
return;
}
else if (value.content && value.content.type === AVG_1.SentenceType.TEXT) {
str = AVG_1.richNodesToCocosString(value.content.value);
if (this._isReview) {
this._reviewPlot = this._reviewPlot + str + "\n";
this._reviewPlot = this._reviewPlot + "<color=#EFDA91>" + "梵优" + ":</c>\n";
this._reviewPlot = this._reviewPlot + str + "\n";
}
}
else {
if (this._isReview) {
this._reviewPlot = this._reviewPlot + str + "\n";
this._reviewPlot = this._reviewPlot + "<color=#EFDA91>" + "梵优" + ":</c>\n";
this._reviewPlot = this._reviewPlot + str + "\n";
}
}
// await this.view.setContent(true, str, roleData.getConfig().name, roleData.getPortrait(this._currPlot!.face), otherPortrait, isShowRouge);
await this.view.setContent(true, str, roleData.getNameIcon(), roleData.getConfig().name, this.getPortraitByRole(roleData, this._currPlot.face), otherPortrait, isShowRouge);
};
if (this._currSelect === undefined || this._currSelect === null) {
let props = {
sentence: content,
backgroundpath: "",
clickcausehide: false,
isFromDate: true,
y: -250,
dateSceneId: this._model.id,
plotId: this._currPlot.id,
onSelectIndexCallback: (index) => { this._currSelect = index; setSelection(); }
};
UIManager_1.UIManager.pushPresenter(SentenceSelectorViewPresenter_1.default, props);
// await this.view.setContent(true, "", roleData.getConfig().name, roleData.getPortrait(this._currPlot!.face), otherPortrait, isShowRouge);
await this.view.setContent(true, "", roleData.getNameIcon(), roleData.getConfig().name, this.getPortraitByRole(roleData, this._currPlot.face), otherPortrait, isShowRouge);
if (this._isDotTutorial) {
// GameDotMgr.getInstance().dotTutorial(TutorialType.Event, TutorialState.SelectSentence, { session: this._model.config.id, plotId: this._currPlot.id });
}
}
else {
await setSelection();
}
}
else {
console.error("不支持的约会剧情", content);
}
}
else { // 没有句子,只设置其立绘、背景等
// await this.view.setContent(false, "", "", roleData.getPortrait(this._currPlot!.face), otherPortrait, isShowRouge);
await this.view.setContent(false, "", "", "", this.getPortraitByRole(roleData, this._currPlot.face), otherPortrait, isShowRouge);
}
if (this._currPlot.sentences[0].actions.actions.length) {
await AVG_1.ActionManager.executeActions(this._currPlot.sentences[0].actions, this.filterFunc, !this._isReview);
}
this._executingPlot = false;
}
else {
// 本次约会剧情结束
this._model.status = DatingEventSceneModel_1.DatingEventStatus.Completed;
this._finished = true;
this.view.setIsRunningAction(false);
this.view.showBackBtn(this._showBackBtn);
if (this._model.isExtra) {
this.view.showRollBackBtn(false);
}
else {
this.view.showRollBackBtn(true);
}
let Plot = AVG_1.PlotManager.getCurrentPlots()[0];
let isToBeContinued = Plot.id == AVG_1.SpecialPlotId.ToBeContinued;
let isEnd = Plot.id == AVG_1.SpecialPlotId.End;
if ((this._isReview || isToBeContinued || isEnd) && !this._model.isExtra) {
let nextKey = this.getNextDatingEventKey();
let nextEventModel = GameModelManager_1.GameModelManager.getMainDatingEventSceneModel(nextKey);
if (nextEventModel) {
if (nextEventModel.status == DatingEventSceneModel_1.DatingEventStatus.Completed) {
this.view.closeView();
let comp = cc.director.getScene().getChildByName("Canvas").getChildByName("VerbRoot").getChildByName("VerbView").getComponent(VerbView_1.default);
// let cfgs = ConfigManager.getAllConfig(dateSceneConfig);
// let ids: string[] = [];
// for (const id in cfgs) {
// if (cfgs[id].DateType == DateType.Date_Normal) {
// ids.push(id);
// }
// }
// let index = ids.indexOf(nextKey.toString());
let plotIds = [];
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
plotIds.push(models[i].id);
}
let index = plotIds.indexOf(nextEventModel.id);
let title = "第" + (index + 1) + "章:";
let cfg = simba_config_manager_1.ConfigManager.getConfig(DateSceneConfig_1.dateSceneConfig, Number(nextKey));
let desc = cfg && cfg.name ? GameModelManager_1.GameModelManager.getConfigLanguageTxt(cfg.name) : "";
comp.toDating(() => {
simba_cc_audio_manager_1.AudioManager.playEffect('verb');
GameModelManager_1.GameModelManager.ForceClickDataReady.emit();
GameModelManager_1.GameModelManager.ForceClickDatingItem.emit(Number(nextKey));
}, { title: title, desc: desc });
}
else {
this.view.guideBack();
if (this._model.isExtra) {
GameModelManager_1.GameModelManager.setBranchComplete(this._model.id);
}
}
}
else {
if (this._model.isExtra) {
GameModelManager_1.GameModelManager.setBranchComplete(this._model.id);
}
this.view.guideBack();
console.log("The nextEventModel is undefined.");
}
}
else if (this._model.isExtra) {
this.view.guideBack();
GameModelManager_1.GameModelManager.setBranchComplete(this._model.id);
console.log("Curr Chapter is extra plot.");
}
else {
GameModelManager_1.GameModelManager.dotMainLinePlotEnd();
// GameModelManager.setProgressDateScene(this._model.id);
GameModelManager_1.GameModelManager.CheckDateSceneProgress.emit();
}
}
}
else if (this._model.isExtra) {
this.view.guideBack();
GameModelManager_1.GameModelManager.setBranchComplete(this._model.id);
console.log("Curr Chapter is extra plot.");
}
}
checkIsShowRouge(plotId) {
let pStart = 1202;
let pEnd = 1229;
let ret = plotId >= pStart && plotId <= pEnd;
// console.log("剧情id = " + plotId + " 是否展示口红: = ", ret);
return ret;
}
getPortraitByRole(role, face = EditorEnums_1.FaceType.Normal, skin) {
let portrait = "";
let curSkin = role.getCurSkin();
if (skin === undefined && curSkin > 0) {
skin = curSkin;
}
portrait = "textures/portrait/" + role.getConfig().id + "/" + (skin !== undefined ? skin + "/" : "") + face;
if (this._model.id === 1) {
portrait = "textures/portrait/" + role.getConfig().id + "/" + face;
}
return portrait;
}
CreateOrUpdateChapterBtns() {
this.view.getScrollViewContentNode().removeAllChildren();
let ret = [];
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
ret.push({ chapterId: i + 1, chapterName: models[i].config.name, chapterStartPlotId: models[i].config.start_plot_id });
}
// for (let i = 0; i < ret.length; ++i) {
// let btn = cc.instantiate(this.view.getChapterBtn());
// btn.getComponent(ChapterBtn).setData(ret[i].chapterId, ret[i].chapterName, ret[i].chapterStartPlotId);
// btn.parent = this.view.getScrollViewContentNode();
// }
for (let i = ret.length - 1; i >= 0; i--) {
let btn = cc.instantiate(this.view.getChapterBtn());
btn.getComponent(ChapterBtn_1.default).setData(ret[i].chapterId, ret[i].chapterName, ret[i].chapterStartPlotId);
btn.parent = this.view.getScrollViewContentNode();
}
}
getRetainVarKeyArr() {
let keyArr = [];
let branches = GameModelManager_1.GameModelManager.getAllStartedBranches();
let branchMap = this.getBranchFirstPlotIdMap();
for (let i = 0; i < branches.length; i++) {
let startPlotId = branches[i].startPlot;
let extraId = branchMap[startPlotId + ""];
if (extraId) {
let recordKey = "de" + extraId;
let f = recordKey + ".f";
let s = recordKey + ".s";
let b = recordKey + ".bg";
if (AVG_1.GameRecord.recordVariables[f]) {
keyArr.push(f);
}
if (AVG_1.GameRecord.recordVariables[s]) {
keyArr.push(s);
}
if (AVG_1.GameRecord.recordVariables[b]) {
keyArr.push(b);
}
}
}
return keyArr;
}
getBranchFirstPlotIdMap() {
let map = {};
let tbl = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
if (tbl) {
for (let id in tbl) {
let c = tbl[id];
if (c && c.DateType == EditorEnums_1.DateType.Date_Sp) {
map[c.start_plot_id + ""] = c.id;
}
}
}
return map;
}
rollBackDateAdArray(pid) {
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
let chapterId = -1;
for (let i = 0; i < models.length; i++) {
if (pid == models[i].config.start_plot_id) {
chapterId = models[i].config.id;
}
}
if (chapterId == -1) {
console.error("Cannot found the chapterId.");
}
let record = AVG_1.GameRecord.globalVariables["date_ad_arr"];
let a = [];
if (record) {
a = JSON.parse(record);
a.sort((a, b) => {
if (a < b) {
return -1;
}
else if (a > b) {
return 1;
}
return 0;
});
for (let i = 0; i < a.length; i++) {
if (a[i] >= chapterId) {
a.splice(i, a.length - (i - 1));
AVG_1.GameRecord.globalVariables["date_ad_arr"] = JSON.stringify(a);
return;
}
}
}
}
getNextDatingEventKey() {
let nextKey = 0;
let currEventId = this._model.id;
let plotIds = [];
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
for (let i = 0; i < models.length; i++) {
plotIds.push(models[i].id);
}
for (let i = 0; i < plotIds.length; i++) {
if (plotIds[i] == currEventId) {
nextKey = plotIds[i + 1];
}
}
// let cfg = ConfigManager.getAllConfig(dateSceneConfig);
// let ids: string[] = [];
// for (const id in cfg) {
// if (cfg[id].DateType == DateType.Date_Normal) {
// ids.push(id);
// }
// }
// for (let i = 0; i < ids.length; i++) {
// if (ids[i] == currEventId.toString()) {
// nextKey = ids[i + 1];
// }
// }
console.log("getNextDatingEventModel", nextKey);
return nextKey;
}
};
DatingScenePresenter.uuid = "DatingScenePresenter";
DatingScenePresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(DatingSceneView_1.DatingSceneViewType)
], DatingScenePresenter);
return DatingScenePresenter;
})();
exports.DatingScenePresenter = DatingScenePresenter;
cc._RF.pop();