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

35 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-12-13 10:58:40 +00:00
import { CCInteger, Component, _decorator } from "cc";
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> {
while (Game.Instance == null) await delay(100);
2022-12-13 10:58:40 +00:00
const testUserData = new UserData();
testUserData.game.metaUpgrades.maxHpLevel = this.maxHpLevel;
testUserData.game.metaUpgrades.bonusDamageLevel = this.bonusDamageLevel;
testUserData.game.metaUpgrades.projectilePiercingLevel = this.projectilePiercingLevel;
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
testUserData.game.metaUpgrades.goldGathererLevel = this.goldGathererLevel;
Game.Instance.playGame(testUserData);
2022-12-12 08:15:27 +00:00
}
}