fixed wave delay
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { EEnemySize } from '../data/EEnemySize';
|
||||||
import { GdRoot } from '../data/GdRoot';
|
import { GdRoot } from '../data/GdRoot';
|
||||||
import { EDirection } from '../util/EDirection';
|
import { EDirection } from '../util/EDirection';
|
||||||
import { Hex } from '../util/Hex';
|
import { Hex } from '../util/Hex';
|
||||||
@@ -23,6 +24,7 @@ export class SimLevel {
|
|||||||
enemiesLeftToSpawn: number = 0;
|
enemiesLeftToSpawn: number = 0;
|
||||||
index: number = 0;
|
index: number = 0;
|
||||||
radius: number = 0;
|
radius: number = 0;
|
||||||
|
spawnDelay: number = 0;
|
||||||
|
|
||||||
constructor(gdRoot: GdRoot, levelIdx: number) {
|
constructor(gdRoot: GdRoot, levelIdx: number) {
|
||||||
const gdLevel = gdRoot.levels[levelIdx];
|
const gdLevel = gdRoot.levels[levelIdx];
|
||||||
@@ -68,14 +70,24 @@ export class SimLevel {
|
|||||||
public startNextWave(simMain: SimMain) {
|
public startNextWave(simMain: SimMain) {
|
||||||
const data = simMain.gdRoot.levels[this.index];
|
const data = simMain.gdRoot.levels[this.index];
|
||||||
this.currentWave += 1;
|
this.currentWave += 1;
|
||||||
if (!data.waves[this.currentWave]) {
|
const gdWave = data.waves[this.currentWave];
|
||||||
|
if (!gdWave) {
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.nextWaveStep = this.currentStep + simMain.gdRoot.simulation.waveDuration * simMain.gdRoot.simulation.stepsPerSecond - 1;
|
|
||||||
this.lastEnemySpawnStep = this.currentStep;
|
this.lastEnemySpawnStep = this.currentStep;
|
||||||
this.enemiesLeftToSpawn = data.waves[this.currentWave].amount;
|
this.enemiesLeftToSpawn = data.waves[this.currentWave].amount;
|
||||||
this.paused = false;
|
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) {
|
public getCellIndex(hex: Hex) {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import { EEnemySize } from '../../data/EEnemySize';
|
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 { SimEnemy } from '../SimEnemy';
|
||||||
import { SimMain } from '../SimMain';
|
import { SimMain } from '../SimMain';
|
||||||
import { ISimAction } from './ISimAction';
|
import { ISimAction } from './ISimAction';
|
||||||
@@ -20,17 +17,7 @@ export class SimActionSpawnEnemies implements ISimAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let spawnDelay = simMain.gdRoot.simulation.spawnDelay;
|
if (level.enemiesLeftToSpawn > 0 && level.lastEnemySpawnStep + level.spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= level.currentStep) {
|
||||||
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) {
|
|
||||||
level.enemiesLeftToSpawn -= 1;
|
level.enemiesLeftToSpawn -= 1;
|
||||||
level.lastEnemySpawnStep = step;
|
level.lastEnemySpawnStep = step;
|
||||||
|
|
||||||
|
|||||||
@@ -24,18 +24,16 @@
|
|||||||
{
|
{
|
||||||
"radius": 9,
|
"radius": 9,
|
||||||
"currency": 1500,
|
"currency": 1500,
|
||||||
"walls": [
|
"walls": [{ "col": 0, "row": 0 }],
|
||||||
{ "col": 0, "row": 0 }
|
|
||||||
],
|
|
||||||
"enemySpawns": [
|
"enemySpawns": [
|
||||||
{ "col": -9, "row": -1},
|
{ "col": -9, "row": -1 },
|
||||||
{ "col": -9, "row": 0},
|
{ "col": -9, "row": 0 },
|
||||||
{ "col": -9, "row": 1}
|
{ "col": -9, "row": 1 }
|
||||||
],
|
],
|
||||||
"enemyTargets": [
|
"enemyTargets": [
|
||||||
{ "col": 8, "row": -1},
|
{ "col": 8, "row": -1 },
|
||||||
{ "col": 9, "row": 0},
|
{ "col": 9, "row": 0 },
|
||||||
{ "col": 8, "row": 1}
|
{ "col": 8, "row": 1 }
|
||||||
],
|
],
|
||||||
"enemyRoutes": [
|
"enemyRoutes": [
|
||||||
[0, 0],
|
[0, 0],
|
||||||
|
|||||||
Reference in New Issue
Block a user