mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Folder structure
This commit is contained in:
18
assets/Scripts/Game/TestGameRunner.ts
Normal file
18
assets/Scripts/Game/TestGameRunner.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Component, _decorator } from "cc";
|
||||
import { GameRunner } from "../Menu/GameRunner";
|
||||
import { delay } from "../Services/Utils/AsyncUtils";
|
||||
import { Game } from "./Game";
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
@ccclass("TestGameRunner")
|
||||
export class TestGameRunner extends Component {
|
||||
public start(): void {
|
||||
if (GameRunner.Instance.IsRunning) return;
|
||||
this.playTestGameAsync();
|
||||
}
|
||||
|
||||
public async playTestGameAsync(): Promise<void> {
|
||||
while (Game.Instance == null) await delay(100);
|
||||
Game.Instance.playGame();
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/TestGameRunner.ts.meta
Normal file
9
assets/Scripts/Game/TestGameRunner.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "605c7b1b-d7fb-4e85-bdcb-9f102cc45197",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
12
assets/Scripts/Utils.meta
Normal file
12
assets/Scripts/Utils.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "a90f4b1c-a934-4656-b7b0-e60a0cfcfd24",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user