f191bdcd-c97b-42b9-b0da-4c695dfed1c6.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
345
346
347
348
349
350
"use strict";
cc._RF.push(module, 'f191b3NyXtCubDaTGld/tHG', 'Launcher');
// script/game/Launcher.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 });
const simba_sdk_1 = require("simba-sdk");
const AVG_1 = require("../avg/AVG");
const CCDummyObjects_1 = require("../common/CCDummyObjects");
const simba_cc_audio_manager_1 = require("simba-cc-audio-manager");
const UIManager_1 = require("../common/gameplay/managers/UIManager");
const AnimationUtils_1 = require("../common/utils/AnimationUtils");
const GameConfig_1 = require("../GameConfig");
const Enums_1 = require("./Enums");
const GameDotMgr_1 = require("./GameDotMgr");
const GameModelManager_1 = require("./model/GameModelManager");
const AlertDialogViewPresenter_1 = require("./ui/presenter/AlertDialogViewPresenter");
const MainViewPresenter_1 = require("./ui/presenter/MainViewPresenter");
const simba_cc_resutils_1 = require("simba-cc-resutils");
const CCGameCenterComponent_1 = require("../cooperation/script/CCGameCenterComponent");
const CCGameCenterNodeFactory_1 = require("../cooperation/script/CCGameCenterNodeFactory");
const CustomerServiceDataCenter_1 = require("../customerService/script/CustomerServiceDataCenter");
const EventCenter_1 = require("../cooperation/event/EventCenter");
const EventKit_1 = require("../cooperation/event/EventKit");
const UnlockSpecialPlotEventManager_1 = require("./model/UnlockSpecialPlotEventManager");
const simba_sdk_exchangecode_1 = require("simba-sdk-exchangecode");
const { ccclass, property } = cc._decorator;
let Launcher = /** @class */ (() => {
let Launcher = class Launcher extends cc.Component {
constructor() {
super(...arguments);
this.progressBar = CCDummyObjects_1.DummyProgressBar;
this.progressLabel = CCDummyObjects_1.DummyLabel;
this.uiRootNode = CCDummyObjects_1.DummyNode;
this.toastParentNode = CCDummyObjects_1.DummyNode;
this.loadingNode = CCDummyObjects_1.DummyNode;
this.loadingRoleNode = CCDummyObjects_1.DummyNode;
this.VerbRoot = CCDummyObjects_1.DummyNode;
this.isLoadGameCenter = false;
this.userIdLabel = CCDummyObjects_1.DummyLabel;
this.hotUpdateNode = CCDummyObjects_1.DummyNode;
this.bgSpr = CCDummyObjects_1.DummySprite;
this.loginCount = 0;
this._gameCenterViewNode = CCDummyObjects_1.DummyNode;
this._disposable = new EventKit_1.CompositeDisposable;
/**控制游戏列表是否展示 */
this.onShowGameCenterListView = (isShow) => {
if (!this._gameCenterViewNode) {
return;
}
this._gameCenterViewNode.active = isShow;
};
this.onGameStart = () => {
this.initializeGame();
};
this.lateInit = async () => {
let mainViewPromise = UIManager_1.UIManager.pushPresenter(MainViewPresenter_1.default, undefined);
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.6, 1, this.progressLabel);
if (CC_DEV) {
globalThis['PlotManager'] = AVG_1.PlotManager;
globalThis['GameRecord'] = AVG_1.GameRecord;
let ConfigManager = require('simba-config-manager');
globalThis['ConfigManager'] = ConfigManager;
}
await AVG_1.initAVG();
//解决清档
await this.dealEmptyRecord();
if (GameConfig_1.GameConfig.EMPTY_RECORD_WHEN_LOGIN) {
AVG_1.PlotManager.stop();
await AVG_1.GameRecord.emptyRecords();
}
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.8, 1, this.progressLabel);
await AVG_1.PlotManager.start(0, false);
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.9, 1, this.progressLabel);
await simba_sdk_exchangecode_1.initExchangeCode();
// init game data
await GameModelManager_1.GameModelManager.init((value) => {
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, value, 1, this.progressLabel);
});
GameDotMgr_1.default.getInstance().dotLoading(Enums_1.LoadingState.LoadingStart);
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.95, 1, this.progressLabel);
GameDotMgr_1.default.getInstance().dotLoading(Enums_1.LoadingState.LoadingEnd);
(await mainViewPromise).start();
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 1.0, 1, this.progressLabel);
// GameDotMgr.getInstance().dotLoading(LoadingState.EnterLobby);
this.loadingNode.active = false;
//检查是否解锁手表次留番外
UnlockSpecialPlotEventManager_1.default.getInstance().nextDayUnlockedSpecialPlot(4);
};
this.loginGame = async () => {
return new Promise(async (resolve, reject) => {
this.loginCount++;
try {
let ret = await simba_sdk_1.SDK.login();
if (ret) {
this.userIdLabel.string = ret.playerId;
await this.lateInit();
resolve();
}
}
catch (error) {
if (this.loginCount > 3) {
this.showLoginFailed();
reject(new Error("登录失败"));
}
else if (error == "timeout") {
this.loginGame();
}
}
});
};
}
async onLoad() {
this.screenAdapter();
if (cc.sys.isNative) {
this._disposable.add(EventCenter_1.EventCenter.GameStart.on(this.onGameStart));
let hotNode = await simba_cc_resutils_1.ResUtils.createWithPrefab('prefab/HotUpdate');
hotNode.parent = this.hotUpdateNode;
}
this.scheduleOnce(() => {
this.preloadView();
this.preloadDir();
});
//关闭fps展示
cc.debug.setDisplayStats(GameConfig_1.GameConfig.showFPS);
/**关闭多点触摸 特效层将不能使用 */
cc.macro.ENABLE_MULTI_TOUCH = false;
this.fixScreenSize();
this.scheduleOnce(async () => {
try {
let node = await simba_cc_resutils_1.ResUtils.createWithPrefab('prefab/ui/VerbView');
node.parent = this.VerbRoot;
}
catch (error) {
console.error(error);
}
if (!this.isLoadGameCenter)
return;
//加载矩阵导量UI
try {
this._disposable.add(EventCenter_1.EventCenter.SHOW_GAME_CENTER_LIST_VIEW.on(this.onShowGameCenterListView));
let gameCenterMomentItem = await simba_cc_resutils_1.ResUtils.loadRes('prefab/cooperation/GameCenterMomentItem', cc.Prefab);
CCGameCenterNodeFactory_1.default.getInstance().registerMomentPrefab(gameCenterMomentItem);
let gameCenterBtn = await simba_cc_resutils_1.ResUtils.loadRes('prefab/cooperation/GameCenterBtn', cc.Prefab);
let gameCenterView = await simba_cc_resutils_1.ResUtils.loadRes('prefab/cooperation/GameCenterView', cc.Prefab);
let cooperationItem = await simba_cc_resutils_1.ResUtils.loadRes('prefab/cooperation/CooperationItem', cc.Prefab);
let cCGameCenterComponent = this.node.addComponent(CCGameCenterComponent_1.default);
cCGameCenterComponent.gameCenterBtnPrefab = gameCenterBtn;
cCGameCenterComponent.gameCenterViewPrefab = gameCenterView;
cCGameCenterComponent.gameCenterItemPrefab = cooperationItem;
cCGameCenterComponent.gameCenterMomentPrefab = gameCenterMomentItem;
cCGameCenterComponent.gameCenterParentNode = this.node;
cCGameCenterComponent.appID = "wx7a067b995e670485";
cCGameCenterComponent.gameID = "yybs";
cCGameCenterComponent.gameChannel = "wechat";
cCGameCenterComponent.isRelease = !GameConfig_1.GameConfig.debug;
cCGameCenterComponent.init();
}
catch (error) {
console.error(error);
}
});
CustomerServiceDataCenter_1.default.getInstance().init();
simba_cc_resutils_1.ResUtils.loadRes("audio/bgm/bayinhe", cc.AudioClip);
simba_cc_resutils_1.ResUtils.loadRes("audio/bgm/wanshengj", cc.AudioClip);
}
/**创建prefab对应的节点 */
createNode(gameCenterViewPrefab) {
if (!gameCenterViewPrefab) {
cc.error("gameCenterViewPrefab is not set , please check it over");
}
else {
this._gameCenterViewNode = cc.instantiate(gameCenterViewPrefab);
}
let parentNode = cc.director.getScene();
this._gameCenterViewNode.parent = parentNode;
this._gameCenterViewNode.position = cc.v3(cc.winSize.width / 2, cc.winSize.height / 2, 0);
}
fixScreenSize() {
// let comp = this.loadingRoleNode.getComponent(PortraitFixComponent);
// if (comp) {
// comp.fixScreenSize(false);
// }
let sf = this.bgSpr.spriteFrame;
this.node.getComponent(cc.Widget).updateAlignment();
let sizeSF = sf.getOriginalSize();
let nodeSize = cc.size(this.node.width, this.node.height);
let scaleTemp = 1;
let scaleX = nodeSize.width / sizeSF.width;
let scaleY = nodeSize.height / sizeSF.height;
scaleTemp = Math.max(scaleX, scaleY);
this.bgSpr.node.scale = scaleTemp;
}
preloadView() {
// let viewList: string[] = [
// 'prefab/ui/MainView',
// 'prefab/ui/MessageView',
// 'prefab/ui/message/MessageEntryItem',
// 'prefab/ui/BedroomView',
// 'prefab/ui/discover/SettingView'
// ]
let viewList = [
'prefab/ui/MainView',
'prefab/ui/MessageView',
'prefab/ui/message/MessageEntryItem'
];
cc.resources.preload(viewList, (error, items) => {
});
}
preloadDir() {
cc.resources.preloadDir('plots'); //剧情数据
cc.resources.preloadDir('userdata/language'); //语言配置
cc.resources.preloadDir('config'); //剧情配置
// cc.resources.preloadDir('textures/items');
}
screenAdapter() {
let winSize = cc.winSize;
if (winSize.width / winSize.height > 720 / 1280) {
let canvas = this.node.getComponent(cc.Canvas);
canvas.fitWidth = true;
canvas.fitHeight = true;
}
}
start() {
if (!cc.sys.isNative)
this.initializeGame();
}
async initializeGame() {
simba_cc_audio_manager_1.AudioManager.init("audio/bgm/", "audio/effect/", "audio/voice/");
while (true) {
try {
await UIManager_1.UIManager.init(this.uiRootNode, this.toastParentNode);
break;
}
catch (e) {
console.error(e);
}
}
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.2);
let ret = false;
let tryCount = 0;
while (!ret && tryCount < 3) {
tryCount++;
ret = await simba_sdk_1.SDK.init();
// initExchangeCode();
}
if (!ret) {
UIManager_1.UIManager.showToast("SDK init failed. sdk初始化失败");
return;
}
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.4, 1, this.progressLabel);
await this.loginGame();
}
showLoginFailed() {
let temp = {
dataptr: {},
titlecontent: "网络错误",
content: "是否重新连接?",
ishasad: false,
istwobtn: true,
adconfig: "",
hasBanner: false,
callback: (type, ret) => {
if (ret) {
this.loginCount = 0;
this.loginGame();
}
else {
cc.director.end();
}
}
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
}
async dealEmptyRecord() {
/**此次执行清档操作的版本号 */
let optionV = "1.0.2";
/**需要清档的玩家注册版本号列表 */
let needEmptyRegVersionArr = ["1.0.0", "1.0.1"];
let emptyVersionRecordKey = "empty_record_versions";
let needEmpty = this.checkIsNeedEmptyRecord(optionV, emptyVersionRecordKey, needEmptyRegVersionArr);
console.log("是否需要清档操作:", needEmpty);
if (needEmpty) {
await AVG_1.GameRecord.emptyRecords();
AVG_1.GameRecord.globalVariables[emptyVersionRecordKey] = optionV;
AVG_1.GameRecord.saveRecord();
}
}
checkIsNeedEmptyRecord(optionV, emptyVersionRecordKey, needEmptyRegVersionArr) {
let empty = false;
let regV = AVG_1.GameRecord.globalVariables["register_version"];
//不存在或者当前注册版本不在需要清档的版本内容中,则直接返回不需要清档
if (!regV || needEmptyRegVersionArr.findIndex((v) => v == regV) === (-1)) {
return false;
}
let emptyRecordVersionString = AVG_1.GameRecord.globalVariables[emptyVersionRecordKey];
if (!emptyRecordVersionString || "" === emptyRecordVersionString.trim()) {
return true;
}
empty = emptyRecordVersionString != optionV;
return empty;
}
};
__decorate([
property({ type: cc.ProgressBar, displayName: "进度条" })
], Launcher.prototype, "progressBar", void 0);
__decorate([
property({ type: cc.Label, displayName: "进度展示文本" })
], Launcher.prototype, "progressLabel", void 0);
__decorate([
property({ type: cc.Node, displayName: "UI根结点" })
], Launcher.prototype, "uiRootNode", void 0);
__decorate([
property({ type: cc.Node, displayName: "场景最上层弱提示根结点" })
], Launcher.prototype, "toastParentNode", void 0);
__decorate([
property({ type: cc.Node, displayName: "加载界面节点" })
], Launcher.prototype, "loadingNode", void 0);
__decorate([
property({ type: cc.Node, displayName: "加载界面人物图" })
], Launcher.prototype, "loadingRoleNode", void 0);
__decorate([
property({ type: cc.Node })
], Launcher.prototype, "VerbRoot", void 0);
__decorate([
property({ tooltip: "是否加载导量UI" })
], Launcher.prototype, "isLoadGameCenter", void 0);
__decorate([
property({ type: cc.Label, displayName: "玩家ID文本" })
], Launcher.prototype, "userIdLabel", void 0);
__decorate([
property({ type: cc.Node, displayName: "热更节点" })
], Launcher.prototype, "hotUpdateNode", void 0);
__decorate([
property(cc.Sprite)
], Launcher.prototype, "bgSpr", void 0);
Launcher = __decorate([
ccclass
], Launcher);
return Launcher;
})();
exports.default = Launcher;
cc._RF.pop();