Slash-The-Hordes/assets/Scripts/Game/TestGameRunner.ts

36 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-12-16 11:01:25 +00:00
import { approx, CCInteger, Component, _decorator } from "cc";
import { AppRoot } from "../AppRoot/AppRoot";
2022-12-12 08:15:27 +00:00
import { GameRunner } from "../Menu/GameRunner";
import { delay } from "../Services/Utils/AsyncUtils";
2022-12-13 10:58:40 +00:00
import { UserData } from "./Data/UserData";
2022-12-12 08:15:27 +00:00
import { Game } from "./Game";
2022-12-13 10:58:40 +00:00
const { ccclass, property } = _decorator;
2022-12-12 08:15:27 +00:00
@ccclass("TestGameRunner")
export class TestGameRunner extends Component {
2022-12-13 10:58:40 +00:00
@property(CCInteger) private maxHpLevel = 0;
@property(CCInteger) private bonusDamageLevel = 0;
@property(CCInteger) private projectilePiercingLevel = 0;
@property(CCInteger) private movementSpeedLevel = 0;
@property(CCInteger) private xpGathererLevel = 0;
@property(CCInteger) private goldGathererLevel = 0;
2022-12-12 08:15:27 +00:00
public start(): void {
if (GameRunner.Instance.IsRunning) return;
this.playTestGameAsync();
}
public async playTestGameAsync(): Promise<void> {
2022-12-16 11:01:25 +00:00
while (Game.Instance == null || AppRoot.Instance == null) await delay(100);
2022-12-13 10:58:40 +00:00
const testUserData = new UserData();
2022-12-16 12:52:54 +00:00
testUserData.game.metaUpgrades.healthLevel = this.maxHpLevel;
testUserData.game.metaUpgrades.overallDamageLevel = this.bonusDamageLevel;
2022-12-13 10:58:40 +00:00
testUserData.game.metaUpgrades.projectilePiercingLevel = this.projectilePiercingLevel;
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
testUserData.game.metaUpgrades.goldGathererLevel = this.goldGathererLevel;
2022-12-16 11:01:25 +00:00
Game.Instance.playGame(testUserData, AppRoot.Instance.Settings, AppRoot.Instance.TranslationData);
2022-12-12 08:15:27 +00:00
}
}