Folder structure

This commit is contained in:
Martin
2022-12-12 09:15:27 +01:00
parent 76ccbd2084
commit f7b345ef93
20 changed files with 855 additions and 367 deletions

View File

@@ -7,6 +7,8 @@ import { delay } from "../Services/Utils/AsyncUtils";
export class GameRunner {
private static instance: GameRunner = new GameRunner();
private isRunning = false;
// eslint-disable-next-line @typescript-eslint/no-empty-function
private constructor() {}
@@ -14,7 +16,12 @@ export class GameRunner {
return this.instance;
}
public get IsRunning(): boolean {
return this.isRunning;
}
public async playGame(): Promise<void> {
this.isRunning = true;
director.loadScene("Game");
const userData: UserData = AppRoot.Instance.SaveSystem.load();
while (Game.Instance == null) await delay(10);
@@ -24,5 +31,7 @@ export class GameRunner {
console.log("Gold coins: " + result);
console.log("All gold coins: " + userData.game.goldCoins);
this.isRunning = false;
}
}

View File

@@ -1,10 +1,11 @@
import { _decorator, Component, Node } from "cc";
import { GameRunner } from "./GameRunner";
const { ccclass, property } = _decorator;
@ccclass("Menu")
export class Menu extends Component {
public start(): void {
public async start(): Promise<void> {
GameRunner.Instance.playGame();
}
}