c09efddb-ffe2-4ded-971e-ab6e4c8d6d4b.js
2.83 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
"use strict";
cc._RF.push(module, 'c09ef3b/+JN7Zceq25MjW1L', 'PlotBranchManager');
// script/game/model/PlotBranchManager.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlotBranchManager = void 0;
const AVG_1 = require("../../avg/AVG");
const UIManager_1 = require("../../common/gameplay/managers/UIManager");
const AlertDialogViewPresenter_1 = require("../ui/presenter/AlertDialogViewPresenter");
var PlotBranchManager;
(function (PlotBranchManager) {
/**存档Key */
const KEY_PLOT_RECORD = 'r_save_p';
const ONLYONE = true;
function savePlotIdToGlobal(recordModel) {
//如果保存的结构体不存在或者存档剧情中的id是剧情结束或者未完待续这两种特殊剧情,弹出提示并直接返回不做存档处理
if (!recordModel || recordModel.plotId === AVG_1.SpecialPlotId.End || recordModel.plotId === AVG_1.SpecialPlotId.ToBeContinued) {
UIManager_1.UIManager.showSceneToast("存档数据错误!");
return;
}
let temp = {
dataptr: {},
titlecontent: "提示",
content: "确定将当前剧情覆盖到存档位吗?",
ishasad: true,
istwobtn: true,
adconfig: "inject_fruit",
hasBanner: false,
callback: (type, ret) => {
if (ret) {
let saveAlredy = checkRecordAlredy(recordModel.plotId);
if (saveAlredy) {
UIManager_1.UIManager.showSceneToast("你已经在此处存储过存档");
}
else {
savePlotRecord(recordModel);
UIManager_1.UIManager.showSceneToast("保存成功");
}
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
}
PlotBranchManager.savePlotIdToGlobal = savePlotIdToGlobal;
/**检测是否已经存档过当前剧情 */
function checkRecordAlredy(pid) {
let ret = false;
let s = AVG_1.GameRecord.globalVariables[KEY_PLOT_RECORD];
if (s && "" !== s.trim()) {
let mArr = JSON.parse(s);
ret = mArr.findIndex((v) => v.plotId === pid) !== (-1);
}
return ret;
}
/**实际存储 */
function savePlotRecord(recordModel) {
let mArr = [];
if (!ONLYONE) {
let s = AVG_1.GameRecord.globalVariables[KEY_PLOT_RECORD];
if (s && "" !== s.trim()) {
mArr = JSON.parse(s);
}
}
mArr.push(recordModel);
AVG_1.GameRecord.globalVariables[KEY_PLOT_RECORD] = JSON.stringify(mArr);
AVG_1.GameRecord.saveRecord();
}
})(PlotBranchManager = exports.PlotBranchManager || (exports.PlotBranchManager = {}));
cc._RF.pop();