Movement settings

This commit is contained in:
Martin 2022-12-12 12:21:59 +01:00
parent fbd201fb44
commit 6cced4ecfc
4 changed files with 6 additions and 3 deletions

View File

@ -64,6 +64,7 @@
"cooldown": 5, "cooldown": 5,
"enemiesPerWave": 30, "enemiesPerWave": 30,
"waveLifetime": 20, "waveLifetime": 20,
"enemyMoveType": "Launch",
"enemyType": "Basic" "enemyType": "Basic"
} }
} }

View File

@ -56,6 +56,6 @@ export class WaveEnemySpawnerSettings {
public cooldown = 0; public cooldown = 0;
public enemiesPerWave = 0; public enemiesPerWave = 0;
public waveLifetime = 0; public waveLifetime = 0;
public moveType = ""; public enemyMoveType = "";
public enemyType = ""; public enemyType = "";
} }

View File

@ -20,7 +20,7 @@ export class WaveEnemySpawner {
this.spawnTimer = new GameTimer(settings.cooldown); this.spawnTimer = new GameTimer(settings.cooldown);
this.enemiesPerWave = settings.enemiesPerWave; this.enemiesPerWave = settings.enemiesPerWave;
this.waveLifetime = settings.waveLifetime; this.waveLifetime = settings.waveLifetime;
this.moveType = <EnemyMovementType>settings.moveType; this.moveType = <EnemyMovementType>settings.enemyMoveType;
this.enemyType = <EnemyType>settings.enemyType; this.enemyType = <EnemyType>settings.enemyType;
} }
@ -60,7 +60,7 @@ export class WaveEnemySpawner {
const randomOffsetY: number = randomRange(-20, 20); const randomOffsetY: number = randomRange(-20, 20);
const posX: number = defaultPosX + randomOffsetX + 50 * (i % side); const posX: number = defaultPosX + randomOffsetX + 50 * (i % side);
const posY: number = defaultPosY + randomOffsetY + 50 * Math.floor(i / side); const posY: number = defaultPosY + randomOffsetY + 50 * Math.floor(i / side);
const enemy = this.enemySpawner.spawnNewEnemy(posX, posY, EnemyMovementType.Launch); const enemy = this.enemySpawner.spawnNewEnemy(posX, posY, this.moveType);
enemies.push(enemy); enemies.push(enemy);
} }

View File

@ -31,6 +31,8 @@ function deleteUnusedProperties(templateSettings: GameSettings, savedSettings: G
} }
function getAllKeys(objectWithKeys: any, prefix = ""): string[] { function getAllKeys(objectWithKeys: any, prefix = ""): string[] {
if (typeof objectWithKeys === "string") return [];
const keys: string[] = []; const keys: string[] = [];
const objectKeys: string[] = Object.keys(objectWithKeys); const objectKeys: string[] = Object.keys(objectWithKeys);