52f06191-b63c-4fbb-9df6-1c1bbda46344.js
10.5 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
"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 PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const DatingSceneView_1 = require("../view/type/DatingSceneView");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const simba_utils_1 = require("simba-utils");
const PlotModel_1 = require("../../../avg/model/PlotModel");
const PlotManager_1 = require("../../../avg/PlotManager");
const PlotsData_1 = require("../../../avg/game-data/PlotsData");
const Enums_1 = require("../../Enums");
const ActionManager_1 = require("../../../avg/ActionManager");
const GameConstData_1 = require("../../../common/gameplay/gamedata/GameConstData");
const RichTextUtils_1 = require("../../../avg/utils/RichTextUtils");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const SentenceSelectorViewPresenter_1 = require("./SentenceSelectorViewPresenter");
const GameModelManager_1 = require("../../model/GameModelManager");
const GameRecord_1 = require("../../../avg/game-data/GameRecord");
const EditorEvents_1 = require("../../../avg/EditorEvents");
const AudioManager_1 = require("../../../common/gameplay/managers/AudioManager");
let DatingScenePresenter = /** @class */ (() => {
let DatingScenePresenter = class DatingScenePresenter extends PresenterBase_1.Presenter {
constructor() {
super(...arguments);
this._executingPlot = false;
this._completingPlot = false;
this._isReview = false;
// private _actionFilter?: (action: DeepReadonly<Action>) => boolean;
this._plotBranch = 0;
this._currSelect = undefined;
this._finished = false;
this.completePlot = async () => {
if (this._executingPlot || this._completingPlot || !this._currPlot || this._finished)
return;
let content = this._currPlot.sentences[0].content;
if (content && content.type === PlotModel_1.SentenceType.SELECT && this._currSelect === undefined)
return;
this._completingPlot = true;
if (this._isReview) {
let nextPlot = await PlotManager_1.PlotManager.getNextPlot(this._currPlot, this._currSelect);
if (nextPlot) {
this._currPlot = nextPlot;
}
}
else {
this._model.status = DatingEventSceneModel_1.DatingEventStatus.InProgress;
let nextPlots = await PlotManager_1.PlotManager.completePlot(this._currPlot, this._currSelect);
this._currPlot = nextPlots[this._plotBranch];
}
this._currSelect = undefined;
this._completingPlot = false;
this.execPlot();
};
}
onOpen(param) {
super.onOpen(param);
this._finished = false;
this.view.completePlotCallback = this.completePlot;
this._model = param;
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 = await PlotsData_1.getPlot(param.config.start_plot_id);
}
else {
let plots = PlotManager_1.PlotManager.getCurrentPlots();
this._plotBranch = plots.findIndex(v => v.plotSceneType === Enums_1.PlotSceneType.DatingEvent && v.plotSceneTypeId === param.id);
this._currPlot = plots[this._plotBranch];
if (this._currPlot.id === this._model.firstPlot.id) {
GameRecord_1.GameRecord.recordVariables.bgm = ""; // 新约会,不继承之前剧情的背景音乐存档
this._model.background = "";
}
this._currSelect = PlotManager_1.PlotManager.getPlotSelection(this._currPlot.id);
if (GameRecord_1.GameRecord.recordVariables.bgm) {
AudioManager_1.AudioManager.playMusic(GameRecord_1.GameRecord.recordVariables.bgm);
}
}
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);
}));
}
onClose() {
UIManager_1.UIManager.popToPresenter(this);
}
async execPlot() {
if (this._currPlot) {
if (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;
if (this._currPlot.portrait !== undefined) {
let otherRole = GameModelManager_1.GameModelManager.getRoleData(this._currPlot.portrait);
if (otherRole) {
otherPortrait = otherRole.getPortrait(this._currPlot.portraitFace);
}
}
if (content) { // TODO 图片设置
if (content.type === PlotModel_1.SentenceType.TEXT) {
await this.view.setContent(sentence.roleId === GameConstData_1.GameConstData.GAME_CONST_PLAYER_ROLE_VALUE, RichTextUtils_1.richNodesToCocosString(content.value), sentence.roleId === 1 ? undefined : roleData.getConfig().name, sentence.roleId === 1 ? otherPortrait : roleData.getPortrait(this._currPlot.face), otherPortrait);
}
else if (content.type === PlotModel_1.SentenceType.SELECT) {
let setSelection = async () => {
let value = content.value[this._currSelect];
let str = value.summary;
if (value.content && value.content.type === PlotModel_1.SentenceType.EMPTY) { // 空类型,不做展示
this.completePlot();
return;
}
else if (value.content && value.content.type === PlotModel_1.SentenceType.TEXT) {
str = RichTextUtils_1.richNodesToCocosString(value.content.value);
}
await this.view.setContent(true, str, roleData.getConfig().name, roleData.getPortrait(this._currPlot.face), otherPortrait);
};
if (this._currSelect === undefined) {
let props = {
sentence: content,
backgroundpath: "",
clickcausehide: false,
optionStyle1: true,
y: -250,
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);
}
else {
await setSelection();
}
}
else {
console.error("不支持的约会剧情", content);
}
}
else { // 没有句子,只设置其立绘、背景等
await this.view.setContent(false, "", "", roleData.getPortrait(this._currPlot.face), otherPortrait);
}
if (this._currPlot.sentences[0].actions.actions.length) {
await ActionManager_1.ActionManager.executeActions(this._currPlot.sentences[0].actions, undefined, !this._isReview);
}
this._executingPlot = false;
}
else {
// 本次约会剧情结束
this._model.status = DatingEventSceneModel_1.DatingEventStatus.Completed;
this._finished = true;
UIManager_1.UIManager.showToast("本次剧情结束");
this.view.guideBack();
}
}
}
};
DatingScenePresenter.uuid = "DatingScenePresenter";
DatingScenePresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(DatingSceneView_1.DatingSceneViewType)
], DatingScenePresenter);
return DatingScenePresenter;
})();
exports.DatingScenePresenter = DatingScenePresenter;
cc._RF.pop();