mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
Test values
This commit is contained in:
parent
83c0be7961
commit
e8fc5a1ec9
@ -195,6 +195,8 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"startTime": 500,
|
||||
"startXP": 10,
|
||||
"maxHpLevel": 0,
|
||||
"bonusDamageLevel": 0,
|
||||
"projectilePiercingLevel": 0,
|
||||
|
@ -78,20 +78,24 @@ export class GeneralEnemySpawnerSettings {
|
||||
public cooldown = 0;
|
||||
}
|
||||
|
||||
export class WaveEnemySpawnerSettings {
|
||||
export class WaveEnemySpawnerSettings implements ISpawner {
|
||||
public common = new GeneralEnemySpawnerSettings();
|
||||
public enemiesToSpawn = 0;
|
||||
}
|
||||
|
||||
export class CircularEnemySpawnerSettings {
|
||||
export class CircularEnemySpawnerSettings implements ISpawner {
|
||||
public common = new GeneralEnemySpawnerSettings();
|
||||
public enemiesToSpawn = 0;
|
||||
}
|
||||
|
||||
export class IndividualEnemySpawnerSettings {
|
||||
export class IndividualEnemySpawnerSettings implements ISpawner {
|
||||
public common = new GeneralEnemySpawnerSettings();
|
||||
}
|
||||
|
||||
export interface ISpawner {
|
||||
common: GeneralEnemySpawnerSettings;
|
||||
}
|
||||
|
||||
export class EnemySettings {
|
||||
public id = "";
|
||||
public moveType = "";
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Camera, Component, JsonAsset, KeyCode, Vec2, _decorator } from "cc";
|
||||
import { runInThisContext } from "vm";
|
||||
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
|
||||
import { delay } from "../Services/Utils/AsyncUtils";
|
||||
import { Background } from "./Background/Background";
|
||||
@ -13,6 +14,7 @@ import { MultiInput } from "./Input/MultiInput";
|
||||
import { VirtualJoystic } from "./Input/VirtualJoystic";
|
||||
import { GameModalLauncher } from "./ModalWIndows/GameModalLauncher";
|
||||
import { Pauser } from "./Pauser";
|
||||
import { TestValues } from "./TestGameRunner";
|
||||
import { GameUI } from "./UI/GameUI";
|
||||
import { EnemyManager } from "./Unit/Enemy/EnemyManager";
|
||||
import { MetaUpgrades } from "./Unit/MetaUpgrades/MetaUpgrades";
|
||||
@ -57,7 +59,12 @@ export class Game extends Component {
|
||||
this.gamePauser.pause();
|
||||
}
|
||||
|
||||
public async playGame(userData: UserData, settings: GameSettings, translationData: TranslationData): Promise<GameResult> {
|
||||
public async playGame(
|
||||
userData: UserData,
|
||||
settings: GameSettings,
|
||||
translationData: TranslationData,
|
||||
testValues?: TestValues
|
||||
): Promise<GameResult> {
|
||||
const metaUpgrades = new MetaUpgrades(userData.game.metaUpgrades, settings.metaUpgrades);
|
||||
|
||||
this.virtualJoystic.init();
|
||||
@ -113,6 +120,12 @@ export class Game extends Component {
|
||||
|
||||
this.gameUI.init(this.player);
|
||||
this.background.init(this.player.node);
|
||||
|
||||
if (testValues) {
|
||||
this.timeAlive += testValues.startTime;
|
||||
this.player.Level.addXp(testValues.startXP);
|
||||
}
|
||||
|
||||
this.gamePauser.resume();
|
||||
|
||||
// while not dead
|
||||
|
@ -1,13 +1,17 @@
|
||||
import { approx, CCInteger, Component, _decorator } from "cc";
|
||||
import { CCInteger, Component, _decorator } from "cc";
|
||||
import { AppRoot } from "../AppRoot/AppRoot";
|
||||
import { GameRunner } from "../Menu/GameRunner";
|
||||
import { delay } from "../Services/Utils/AsyncUtils";
|
||||
import { GameSettings, ISpawner } from "./Data/GameSettings";
|
||||
import { UserData } from "./Data/UserData";
|
||||
import { Game } from "./Game";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("TestGameRunner")
|
||||
export class TestGameRunner extends Component {
|
||||
@property(CCInteger) private startTime = 0;
|
||||
@property(CCInteger) private startXP = 0;
|
||||
|
||||
@property(CCInteger) private maxHpLevel = 0;
|
||||
@property(CCInteger) private bonusDamageLevel = 0;
|
||||
@property(CCInteger) private projectilePiercingLevel = 0;
|
||||
@ -30,6 +34,28 @@ export class TestGameRunner extends Component {
|
||||
testUserData.game.metaUpgrades.movementSpeedLevel = this.movementSpeedLevel;
|
||||
testUserData.game.metaUpgrades.xpGathererLevel = this.xpGathererLevel;
|
||||
testUserData.game.metaUpgrades.goldGathererLevel = this.goldGathererLevel;
|
||||
Game.Instance.playGame(testUserData, AppRoot.Instance.Settings, AppRoot.Instance.TranslationData);
|
||||
|
||||
const settings = this.getTimeModifiedSettings(AppRoot.Instance.Settings);
|
||||
Game.Instance.playGame(testUserData, settings, AppRoot.Instance.TranslationData, { startTime: this.startTime, startXP: this.startXP });
|
||||
}
|
||||
|
||||
private getTimeModifiedSettings(settings: GameSettings): GameSettings {
|
||||
const spawners: ISpawner[] = [
|
||||
...settings.enemyManager.circularEnemySpawners,
|
||||
...settings.enemyManager.individualEnemySpawners,
|
||||
...settings.enemyManager.waveEnemySpawners
|
||||
];
|
||||
|
||||
for (const spawner of spawners) {
|
||||
spawner.common.startDelay -= this.startTime;
|
||||
spawner.common.stopDelay -= this.startTime;
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestValues {
|
||||
public startTime = 0;
|
||||
public startXP = 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, _decorator } from "cc";
|
||||
import { UnitHealth } from "../UnitHealth";
|
||||
import { UnitHealth } from "../../UnitHealth";
|
||||
import { PlayerHealthUI } from "./PlayerHealthUI";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
@ -40,5 +40,7 @@ export class UnitLevel {
|
||||
this.currentLevel++;
|
||||
|
||||
this.levelUpEvent.trigger(this.currentLevel);
|
||||
|
||||
this.tryLevelUp();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user