5bcc8dd6-cc23-448f-bc19-a6292ec711a0.js
16.8 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
"use strict";
cc._RF.push(module, '5bcc83WzCNEj7wZpikuxxGg', 'ExtraPlotDatingEventSubViewPresenter');
// script/game/ui/presenter/ExtraPlotDatingEventSubViewPresenter.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.ExtraPlotDatingEventSubViewPresenter = void 0;
const simba_config_manager_1 = require("simba-config-manager");
const AVG_1 = require("../../../avg/AVG");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const StringUtils_1 = require("../../../common/utils/StringUtils");
const DateSceneConfig_1 = require("../../../config/DateSceneConfig");
const Enums_1 = require("../../Enums");
const GameDotMgr_1 = require("../../GameDotMgr");
const CDKeyEventManager_1 = require("../../model/CDKeyEventManager");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const ExtraStoryModelManager_1 = require("../../model/ExtraStoryModelManager");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const ExtraPlotDatingEventSubView_1 = require("../view/type/ExtraPlotDatingEventSubView");
const AlertDialogViewPresenter_1 = require("./AlertDialogViewPresenter");
const DatingScenePresenter_1 = require("./DatingScenePresenter");
const GuideViewPresenter_1 = require("./GuideViewPresenter");
let ExtraPlotDatingEventSubViewPresenter = /** @class */ (() => {
let ExtraPlotDatingEventSubViewPresenter = class ExtraPlotDatingEventSubViewPresenter extends PresenterBase_1.Subpresenter {
constructor() {
super(...arguments);
this._modelMap = {};
this._dailySceneNum = -1;
this._curChapterIndex = 1;
this._maxChapterIndex = 1;
this._maxChapterIsChange = false;
this.onItemAdModeClick = (key) => {
GameModelManager_1.GameModelManager.setGuideEventItemRecord(key, Enums_1.GuideState.Complete);
let m = this._modelMap[key];
let hasRecord = this.checkIsSceneHasAdRecord(m.id);
CDKeyEventManager_1.default.getInstance().shiftCDKeyRemovePlotAD();
let removeAdCardNum = CDKeyEventManager_1.default.getInstance().checkCDKeyRemovePlotAD();
if (m.status !== DatingEventSceneModel_1.DatingEventStatus.Completed) {
GameDotMgr_1.default.getInstance().dotClickUI("click_date_card" + m.config.id);
}
let showAdAlert = !(removeAdCardNum > 0) && !hasRecord && m.config.ads === 1 && m.status == DatingEventSceneModel_1.DatingEventStatus.New;
if (showAdAlert) {
let temp = {
dataptr: { key },
titlecontent: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_WAIT_VALUE),
content: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_SHOW_AD_UNLOCK_DATE_VALUE),
ishasad: true,
istwobtn: true,
adconfig: "inject_fruit",
location: Enums_1.CommonLocation.Event,
callback: this.showAdCallBack,
hasBanner: false,
isthreebtn: true
};
console.log("Push AlertDialogViewPros data end");
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
console.log("pushPresenter=========");
}
else {
this.enterDatingScene(key);
}
};
this.showAdCallBack = (type, ret, param) => {
if (ret) {
if (true) {
let key = param["key"];
let m = this._modelMap[key];
this.pushSceneAdToRecord(m.id);
setTimeout(() => {
this.enterDatingScene(key);
}, 300);
}
}
};
this.checkGuideItem = () => {
let k = GameModelManager_1.GameModelManager.getEventItemGuideKey();
if (k && "" !== k) {
let node = this.view.getItemNode(k);
if (node) {
let wp = node.convertToWorldSpaceAR(cc.v2(0, 0));
let m = {
x: wp.x,
y: wp.y,
w: node.width,
h: node.height,
d: Enums_1.DirectionType.DOWM,
call: () => {
this.onItemAdModeClick(k);
// this.onItemEnergyCostClick(k);
GameModelManager_1.GameModelManager.setGuideEventItemRecord(k, Enums_1.GuideState.Complete);
}
};
UIManager_1.UIManager.pushPresenter(GuideViewPresenter_1.default, m);
GameDotMgr_1.default.getInstance().dotGuide(Enums_1.GuideOperationType.Show, Enums_1.GuideLocation.EventItem);
}
}
};
this.onOptionChapter = (stepType) => {
let tempIndex = stepType === Enums_1.StepType.Add ? this._curChapterIndex + 1 : this._curChapterIndex - 1;
this._curChapterIndex = tempIndex >= 1 && tempIndex <= this._maxChapterIndex ? tempIndex : this._curChapterIndex;
this.refreshItems();
};
this.onRefreshDateSceneProgress = () => {
this.refreshItems();
};
this.onForceClickItem = (id) => {
console.log("DatingEventSubpresenter onForceClickItem id = ", id);
let k = id + "";
if (!this._modelMap || !this._modelMap[k]) {
return;
}
this.onItemAdModeClick(k);
};
this.onRefreshExtraPlotByType = (id) => {
this._curChapterIndex = id;
this.refreshItems();
};
}
sceneModelToViewModel(item, index) {
this._modelMap[item.id.toString()] = item;
let direct = Enums_1.DatePrefabDirectType.Left;
if (this._curChapterIndex % 2 === 1) {
direct = (index + 1) % 2 === 1 ? Enums_1.DatePrefabDirectType.Left : Enums_1.DatePrefabDirectType.Right;
}
else {
direct = (index + 1) % 2 === 0 ? Enums_1.DatePrefabDirectType.Left : Enums_1.DatePrefabDirectType.Right;
}
return {
key: item.id + "",
title: GameModelManager_1.GameModelManager.getConfigLanguageTxt(item.config.name),
status: item.status,
coverImage: "textures/dating_event/cover/" + item.config.background,
itype: direct
};
}
// async refreshItems() {
// let items: ExtraDateItemViewProps[] = [];
// let cfgIdArr: number[] = this.getCfgIdArr();
// let role = GameModelManager.getRoleData(this._viewProps.roleId);
// for (let i = 0; i < cfgIdArr.length; i++) {
// let cfg = ConfigManager.getConfig(extraSceneConfig, cfgIdArr[i]);
// if (role && role.getRelationValue() >= cfg.relationCondition) {
// await ExtraStoryModelManager.startBranches([cfg.start_plot_id]);
// }
// let sceneModel = new DatingEventSceneModel(cfg.id, false);
// await sceneModel.initFromRecords();
// if (sceneModel.status === DatingEventStatus.Locked && role!.getRelationValue() >= cfg.relationCondition) {
// sceneModel.status = DatingEventStatus.New;
// }
// let p = this.sceneModelToViewModel(sceneModel);
// p.showLine = i !== cfgIdArr.length - 1;
// items.push(p);
// }
// this._viewProps.items = items;
// }
async refreshItems() {
let items = [];
let srcModels = [];
let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
for (const id in cfg) {
if (cfg[id].DateType == EditorEnums_1.DateType.Date_Sp && cfg[id].chapter_index == this._curChapterIndex) {
await ExtraStoryModelManager_1.ExtraStoryModelManager.startBranches([cfg[id].start_plot_id]);
let plot = await AVG_1.getPlot(cfg[id].start_plot_id);
let model = new DatingEventSceneModel_1.DatingEventSceneModel(Number(id));
// model.status = ExtraStoryModelManager.getBranchStatus(model.id, model.config.start_plot_id);
await model.initFromRecords();
if (model.status === DatingEventSceneModel_1.DatingEventStatus.Locked) {
model.status = DatingEventSceneModel_1.DatingEventStatus.New;
}
// model.firstPlot = plot;
model.isExtra = true;
srcModels.push(model);
}
}
for (let i = srcModels.length - 1; i >= 0; i--) {
items.push(this.sceneModelToViewModel(srcModels[i], i));
}
if (this._dailySceneNum == -1) {
let maxItemsNum = 0;
let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
for (let id in cfg) {
let c = cfg[id];
if (c) {
maxItemsNum++;
}
}
this._dailySceneNum = maxItemsNum;
}
let showContinue = false;
if (srcModels.length !== 0) {
let c = 0;
let cfgs = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
for (let id in cfgs) {
let cfg = cfgs[id];
if (cfg) {
c++;
}
}
let last = srcModels[srcModels.length - 1];
showContinue = last.id === c;
}
this.view.setProps({
items,
onItemClick: this.onItemAdModeClick,
showContinue: showContinue,
chapterName: this.getChapterName(this._curChapterIndex),
showLeft: this._curChapterIndex !== 1,
showRight: this._curChapterIndex !== this._maxChapterIndex,
showChapterClear: this.checkChapterClear(items, this._curChapterIndex),
onOptionChapter: this.onOptionChapter,
chapterIndex: this._curChapterIndex
});
}
checkChapterClear(items, chapterIndex) {
let showClear = true;
let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
let cnt = 0;
for (let id in cfg) {
let c = cfg[id];
if (c && c.chapter_index === chapterIndex) {
cnt++;
}
}
if (cnt !== items.length) {
return false;
}
return showClear;
}
getChapterName(chapterIndex) {
chapterIndex -= 1;
let nameArr = [
"一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十"
];
let name = StringUtils_1.StringUtils.format(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_CHAPTER_NAME), nameArr[chapterIndex]);
return name;
}
checkIsSceneHasAdRecord(id) {
let ret = false;
let record = AVG_1.GameRecord.globalVariables["date_ad_arr"];
if (record) {
let a = JSON.parse(record);
let i = a.findIndex((v) => v === id);
ret = i !== -1;
}
return ret;
}
pushSceneAdToRecord(id) {
let record = AVG_1.GameRecord.globalVariables["date_ad_arr"];
let a = [];
let isExsit = false;
if (record) {
a = JSON.parse(record);
let i = a.findIndex((v) => v === id);
if (i >= 0) {
isExsit = true;
}
}
if (!isExsit) {
a.push(id);
a.reverse();
AVG_1.GameRecord.globalVariables["date_ad_arr"] = JSON.stringify(a);
AVG_1.GameRecord.autoSave();
}
}
enterDatingScene(key) {
ExtraStoryModelManager_1.ExtraStoryModelManager.enterExtraStoryByStartPlotId(this._modelMap[key].config.start_plot_id);
GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(false);
UIManager_1.UIManager.pushPresenter(DatingScenePresenter_1.DatingScenePresenter, this._modelMap[key], true);
}
onOwnerShow() {
if (!this.view.isHidden) {
this.selectCurChapter();
this.refreshMaxChapterIndex();
// this.refreshItems();
}
}
onOwnerEnterForeground() {
if (!this.view.isHidden) {
this.refreshMaxChapterIndex();
this.refreshItems();
}
if (this._maxChapterIsChange) {
this.selectCurChapter();
}
}
onOpen() {
super.onOpen();
this._disposable.add(GameModelManager_1.GameModelManager.CheckDateGuide.on(this.checkGuideItem));
this._disposable.add(GameModelManager_1.GameModelManager.RefreshDateSceneProgress.on(this.onRefreshDateSceneProgress));
this._disposable.add(GameModelManager_1.GameModelManager.ForceClickDatingItem.on(this.onForceClickItem));
this._disposable.add(GameModelManager_1.GameModelManager.RefreshExtraPlotByType.on(this.onRefreshExtraPlotByType));
this.selectCurChapter();
if (!this.view.isHidden) {
this.refreshMaxChapterIndex();
this.onShow();
}
}
onShow() {
this.refreshMaxChapterIndex();
// this.refreshItems();
this.checkGuideItem();
}
onHide() {
}
selectCurChapter() {
let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
if (models && models.length) {
let last = models[models.length - 1];
this._curChapterIndex = last.config.chapter_index;
if (this._curChapterIndex !== 1) {
GameModelManager_1.GameModelManager.setNotNeedEnterCurDateChapter();
}
}
}
refreshMaxChapterIndex() {
let maxChapterIndex = this._maxChapterIndex;
let arr = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
if (arr && arr.length) {
let dId = arr[arr.length - 1].id;
let cfg = simba_config_manager_1.ConfigManager.getConfig(DateSceneConfig_1.dateSceneConfig, dId);
this._maxChapterIndex = cfg.chapter_index;
}
this._maxChapterIsChange = maxChapterIndex == this._maxChapterIndex ? false : true;
}
};
ExtraPlotDatingEventSubViewPresenter = __decorate([
PresenterCCViewFactory_1.RegSubpresenter(ExtraPlotDatingEventSubView_1.ExtraPlotDatingEventSubViewType)
], ExtraPlotDatingEventSubViewPresenter);
return ExtraPlotDatingEventSubViewPresenter;
})();
exports.ExtraPlotDatingEventSubViewPresenter = ExtraPlotDatingEventSubViewPresenter;
cc._RF.pop();