From fae633ea5414fb2b6498154a132fcbaaf5757518 Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Sun, 15 Jun 2025 11:20:07 +0200 Subject: [PATCH] fixed wave delay --- src/app/components/game/sim/SimLevel.ts | 16 ++++- .../game/sim/actions/SimActionSpawnEnemies.ts | 15 +---- src/assets/data/gdRoot.json | 60 +++++++++---------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/app/components/game/sim/SimLevel.ts b/src/app/components/game/sim/SimLevel.ts index 800ba07..9676d0a 100644 --- a/src/app/components/game/sim/SimLevel.ts +++ b/src/app/components/game/sim/SimLevel.ts @@ -1,3 +1,4 @@ +import { EEnemySize } from '../data/EEnemySize'; import { GdRoot } from '../data/GdRoot'; import { EDirection } from '../util/EDirection'; import { Hex } from '../util/Hex'; @@ -23,6 +24,7 @@ export class SimLevel { enemiesLeftToSpawn: number = 0; index: number = 0; radius: number = 0; + spawnDelay: number = 0; constructor(gdRoot: GdRoot, levelIdx: number) { const gdLevel = gdRoot.levels[levelIdx]; @@ -68,14 +70,24 @@ export class SimLevel { public startNextWave(simMain: SimMain) { const data = simMain.gdRoot.levels[this.index]; this.currentWave += 1; - if (!data.waves[this.currentWave]) { + const gdWave = data.waves[this.currentWave]; + if (!gdWave) { this.paused = true; return; } - this.nextWaveStep = this.currentStep + simMain.gdRoot.simulation.waveDuration * simMain.gdRoot.simulation.stepsPerSecond - 1; this.lastEnemySpawnStep = this.currentStep; this.enemiesLeftToSpawn = data.waves[this.currentWave].amount; this.paused = false; + this.spawnDelay = simMain.gdRoot.simulation.spawnDelay; + switch (gdWave.size) { + case EEnemySize.Huge: + this.spawnDelay *= 2; + break; + case EEnemySize.Tiny: + this.spawnDelay *= 0.5; + break; + } + this.nextWaveStep = this.currentStep + (simMain.gdRoot.simulation.waveDuration + gdWave.amount * this.spawnDelay) * simMain.gdRoot.simulation.stepsPerSecond - 1; } public getCellIndex(hex: Hex) { diff --git a/src/app/components/game/sim/actions/SimActionSpawnEnemies.ts b/src/app/components/game/sim/actions/SimActionSpawnEnemies.ts index 269d304..260e41e 100644 --- a/src/app/components/game/sim/actions/SimActionSpawnEnemies.ts +++ b/src/app/components/game/sim/actions/SimActionSpawnEnemies.ts @@ -1,7 +1,4 @@ import { EEnemySize } from '../../data/EEnemySize'; -import { Hex } from '../../util/Hex'; -import { PathFinding } from '../../util/PathFinding'; -import { SimCommandStartNextWave } from '../commands/SimCommandStartNextWave'; import { SimEnemy } from '../SimEnemy'; import { SimMain } from '../SimMain'; import { ISimAction } from './ISimAction'; @@ -19,18 +16,8 @@ export class SimActionSpawnEnemies implements ISimAction { if (!gdWave) { return; } - - let spawnDelay = simMain.gdRoot.simulation.spawnDelay; - switch (gdWave.size) { - case EEnemySize.Huge: - spawnDelay *= 2; - break; - case EEnemySize.Tiny: - spawnDelay *= 0.5; - break; - } - if (level.enemiesLeftToSpawn > 0 && level.lastEnemySpawnStep + spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= level.currentStep) { + if (level.enemiesLeftToSpawn > 0 && level.lastEnemySpawnStep + level.spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= level.currentStep) { level.enemiesLeftToSpawn -= 1; level.lastEnemySpawnStep = step; diff --git a/src/assets/data/gdRoot.json b/src/assets/data/gdRoot.json index 5229745..3b50402 100644 --- a/src/assets/data/gdRoot.json +++ b/src/assets/data/gdRoot.json @@ -6,36 +6,34 @@ ], "towers": [ { - "cost": 75, - "projectileEffect": { - "type": 0, - "amount": 2, - "speed": 10 - }, - "projectileRange": 2, - "projectileRate": 5, - "projectileSize": 0.2, - "aoeEffect": null, - "aoeRange": 0, - "aoeRate": 0 + "cost": 75, + "projectileEffect": { + "type": 0, + "amount": 2, + "speed": 10 + }, + "projectileRange": 2, + "projectileRate": 5, + "projectileSize": 0.2, + "aoeEffect": null, + "aoeRange": 0, + "aoeRate": 0 } ], "levels": [ { "radius": 9, "currency": 1500, - "walls": [ - { "col": 0, "row": 0 } - ], + "walls": [{ "col": 0, "row": 0 }], "enemySpawns": [ - { "col": -9, "row": -1}, - { "col": -9, "row": 0}, - { "col": -9, "row": 1} + { "col": -9, "row": -1 }, + { "col": -9, "row": 0 }, + { "col": -9, "row": 1 } ], "enemyTargets": [ - { "col": 8, "row": -1}, - { "col": 9, "row": 0}, - { "col": 8, "row": 1} + { "col": 8, "row": -1 }, + { "col": 9, "row": 0 }, + { "col": 8, "row": 1 } ], "enemyRoutes": [ [0, 0], @@ -49,16 +47,16 @@ [2, 2] ], "waves": [ - { "enemy": 0, "size": 1, "amount": 10, "gain": 3, "hitpoints": 10 }, - { "enemy": 0, "size": 1, "amount": 10, "gain": 5, "hitpoints": 20 }, - { "enemy": 0, "size": 0, "amount": 50, "gain": 7, "hitpoints": 5 }, - { "enemy": 0, "size": 1, "amount": 15, "gain": 10, "hitpoints": 30 }, - { "enemy": 0, "size": 2, "amount": 3, "gain": 50, "hitpoints": 200 }, - { "enemy": 0, "size": 1, "amount": 10, "gain": 10, "hitpoints": 60 }, - { "enemy": 0, "size": 1, "amount": 10, "gain": 15, "hitpoints": 70 }, - { "enemy": 0, "size": 1, "amount": 15, "gain": 20, "hitpoints": 80 }, - { "enemy": 0, "size": 1, "amount": 15, "gain": 25, "hitpoints": 90 }, - { "enemy": 0, "size": 2, "amount": 3, "gain": 100, "hitpoints": 500 } + { "enemy": 0, "size": 1, "amount": 10, "gain": 3, "hitpoints": 10 }, + { "enemy": 0, "size": 1, "amount": 10, "gain": 5, "hitpoints": 20 }, + { "enemy": 0, "size": 0, "amount": 50, "gain": 7, "hitpoints": 5 }, + { "enemy": 0, "size": 1, "amount": 15, "gain": 10, "hitpoints": 30 }, + { "enemy": 0, "size": 2, "amount": 3, "gain": 50, "hitpoints": 200 }, + { "enemy": 0, "size": 1, "amount": 10, "gain": 10, "hitpoints": 60 }, + { "enemy": 0, "size": 1, "amount": 10, "gain": 15, "hitpoints": 70 }, + { "enemy": 0, "size": 1, "amount": 15, "gain": 20, "hitpoints": 80 }, + { "enemy": 0, "size": 1, "amount": 15, "gain": 25, "hitpoints": 90 }, + { "enemy": 0, "size": 2, "amount": 3, "gain": 100, "hitpoints": 500 } ] } ],