enemy spawn and next wave start refactoring

This commit is contained in:
2025-06-15 11:14:12 +02:00
parent d26999ace9
commit 337a3d8213
4 changed files with 47 additions and 31 deletions

View File

@@ -5,6 +5,7 @@ import { PathFinding } from '../util/PathFinding';
import { ECellType } from './ECellType';
import { SimCell } from './SimCell';
import { SimEnemy } from './SimEnemy';
import { SimMain } from './SimMain';
import { SimProjectile } from './SimProjectile';
export class SimLevel {
@@ -63,6 +64,19 @@ export class SimLevel {
this.updatePaths(gdRoot);
}
public startNextWave(simMain: SimMain) {
const data = simMain.gdRoot.levels[this.index];
this.currentWave += 1;
if (!data.waves[this.currentWave]) {
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;
}
public getCellIndex(hex: Hex) {
const x = hex.col + this.radius;