-
-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathstartContinueGame.ts
More file actions
51 lines (48 loc) · 1.79 KB
/
startContinueGame.ts
File metadata and controls
51 lines (48 loc) · 1.79 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
import { assetSetter, fileType } from '../../util/gameAssetsAccess/assetSetter';
import { sceneFetcher } from '../scene/sceneFetcher';
import { sceneParser } from '../../parser/sceneParser';
import { resetStage } from '@/Core/controller/stage/resetStage';
import { webgalStore } from '@/store/store';
import { setVisibility } from '@/store/GUIReducer';
import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
import { setEbg } from '@/Core/gameScripts/changeBg/setEbg';
import { restorePerform } from '@/Core/controller/storage/jumpFromBacklog';
import { hasFastSaveRecord, loadFastSaveGame } from '@/Core/controller/storage/fastSaveLoad';
import { WebGAL } from '@/Core/WebGAL';
/**
* 从头开始游戏
*/
export const startGame = () => {
resetStage(true);
// 重新获取初始场景
const sceneUrl: string = assetSetter('start.txt', fileType.scene);
// 场景写入到运行时
sceneFetcher(sceneUrl).then((rawScene) => {
WebGAL.sceneManager.sceneData.currentScene = sceneParser(rawScene, 'start.txt', sceneUrl);
// 开始第一条语句
nextSentence();
});
webgalStore.dispatch(setVisibility({ component: 'showTitle', visibility: false }));
};
export async function continueGame() {
/**
* 重设模糊背景
*/
setEbg(webgalStore.getState().stage.bgName);
// 当且仅当游戏未开始时使用快速存档
// 当游戏开始后 使用原来的逻辑
if ((await hasFastSaveRecord()) && WebGAL.sceneManager.sceneData.currentSentenceId === 0) {
// 恢复记录
await loadFastSaveGame();
return;
}
if (
WebGAL.sceneManager.sceneData.currentSentenceId === 0 &&
WebGAL.sceneManager.sceneData.currentScene.sceneName === 'start.txt'
) {
// 如果游戏没有开始,开始游戏
nextSentence();
} else {
restorePerform();
}
}