Launcher.js
4.95 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
"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 GameConfig_1 = require("../GameConfig");
const UIManager_1 = require("../common/gameplay/managers/UIManager");
const AnimationUtils_1 = require("../common/utils/AnimationUtils");
const PlotManager_1 = require("../avg/PlotManager");
const simba_sdk_1 = require("simba-sdk");
const GameModelManager_1 = require("./model/GameModelManager");
const MainViewPresenter_1 = require("./ui/presenter/MainViewPresenter");
const CCDummyObjects_1 = require("../common/CCDummyObjects");
const AudioManager_1 = require("../common/gameplay/managers/AudioManager");
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.guideRootNode = CCDummyObjects_1.DummyNode;
this.VerbRoot = CCDummyObjects_1.DummyNode;
}
onLoad() {
let winSize = cc.winSize;
if (winSize.width / winSize.height > 720 / 1280) {
let canvas = this.node.getComponent(cc.Canvas);
canvas.fitWidth = true;
canvas.fitHeight = true;
}
//关闭fps展示
cc.debug.setDisplayStats(GameConfig_1.GameConfig.showFPS);
cc.macro.ENABLE_MULTI_TOUCH = false;
}
start() {
this.initializeGame();
}
async initializeGame() {
AudioManager_1.AudioManager.init("audio/bgm/", "audio/effect/", "audio/voice/");
await UIManager_1.UIManager.init(this.uiRootNode);
let mainViewPromise = UIManager_1.UIManager.pushPresenter(MainViewPresenter_1.default, undefined);
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();
}
if (!ret) {
// TODO show error alert
console.error("SDK init failed.");
return;
}
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.4, 1, this.progressLabel);
tryCount = 0;
while (1) {
try {
tryCount++;
await simba_sdk_1.SDK.login();
break;
}
catch (e) {
if (tryCount > 3) {
console.log("SDK login failed.");
return;
}
}
}
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.6, 1, this.progressLabel);
await PlotManager_1.PlotManager.init();
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 0.8, 1, this.progressLabel);
await PlotManager_1.PlotManager.start();
// init game data
await GameModelManager_1.GameModelManager.init();
AnimationUtils_1.AnimationUtils.animateProgress(this.progressBar, 1.0, 1, this.progressLabel);
await (await mainViewPromise).start();
this.node.getChildByName("Loading").active = false;
}
async startGame() {
}
};
__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, "guideRootNode", void 0);
__decorate([
property({ type: cc.Node, displayName: '转场根节点' })
], Launcher.prototype, "VerbRoot", void 0);
Launcher = __decorate([
ccclass
], Launcher);
return Launcher;
})();
exports.default = Launcher;
cc._RF.pop();