fixed wave delay

This commit is contained in:
2025-06-15 11:20:07 +02:00
parent 337a3d8213
commit fae633ea54
3 changed files with 44 additions and 47 deletions

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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 }
]
}
],