migrate from perforce
This commit is contained in:
31
dist/Simulation/Actions/SimActionSpawnEnemies.js
vendored
Normal file
31
dist/Simulation/Actions/SimActionSpawnEnemies.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { EEnemySize } from "../../GameData/index.js";
|
||||
import { SimCommandStartNextWave, SimEnemy } from "../index.js";
|
||||
export class SimActionSpawnEnemies {
|
||||
execute(simMain) {
|
||||
const simLevel = simMain.currentLevel;
|
||||
const gdLevel = simLevel.gdLevel;
|
||||
const step = simLevel.currentStep;
|
||||
const wave = gdLevel.waves[simLevel.currentWave];
|
||||
let spawnDelay = simMain.gdRoot.simulation.spawnDelay;
|
||||
switch (wave.size) {
|
||||
case EEnemySize.Huge:
|
||||
spawnDelay *= 2;
|
||||
break;
|
||||
case EEnemySize.Tiny:
|
||||
spawnDelay *= 0.5;
|
||||
break;
|
||||
}
|
||||
if (simLevel.enemiesLeftToSpawn > 0 && simLevel.lastEnemySpawnStep + spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= simLevel.currentStep) {
|
||||
simLevel.enemiesLeftToSpawn -= 1;
|
||||
simLevel.lastEnemySpawnStep = step;
|
||||
const route = Math.floor(Math.random() * gdLevel.enemyRoutes.length);
|
||||
const enemy = new SimEnemy(simMain.gdRoot, wave, route, simLevel);
|
||||
enemy.onPathUpdated();
|
||||
simLevel.simEnemies.push(enemy);
|
||||
}
|
||||
if (simLevel.nextWaveStep == step && !!gdLevel.waves[simLevel.currentWave + 1]) {
|
||||
simMain.addCommand(new SimCommandStartNextWave(simMain.gdRoot, simLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SimActionSpawnEnemies.js.map
|
||||
Reference in New Issue
Block a user