mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
Rename to wave
This commit is contained in:
parent
8e38cbfb27
commit
5a98d691e1
@ -8,7 +8,7 @@ import { EnemyType } from "./EnemyType";
|
||||
|
||||
export class WaveEnemySpawner {
|
||||
private spawnTimer: GameTimer = new GameTimer(5);
|
||||
private groups: EnemyGroupWithLifetime[] = [];
|
||||
private waves: EnemyWave[] = [];
|
||||
public constructor(
|
||||
private enemySpawner: EnemySpawner,
|
||||
private enemiesToSpawn: number,
|
||||
@ -24,15 +24,15 @@ export class WaveEnemySpawner {
|
||||
}
|
||||
|
||||
private tryRemoveExpiredEnemies(deltaTime: number): void {
|
||||
for (let i = this.groups.length - 1; 0 <= i; i--) {
|
||||
const group: EnemyGroupWithLifetime = this.groups[i];
|
||||
group.lifeTimeLeft -= deltaTime;
|
||||
if (group.lifeTimeLeft <= 0) {
|
||||
for (const enemy of group.enemies) {
|
||||
for (let i = this.waves.length - 1; 0 <= i; i--) {
|
||||
const wave: EnemyWave = this.waves[i];
|
||||
wave.lifeTimeLeft -= deltaTime;
|
||||
if (wave.lifeTimeLeft <= 0) {
|
||||
for (const enemy of wave.enemies) {
|
||||
this.enemySpawner.returnEnemy(enemy);
|
||||
}
|
||||
|
||||
this.groups.splice(i, 1);
|
||||
this.waves.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,12 +53,12 @@ export class WaveEnemySpawner {
|
||||
enemies.push(enemy);
|
||||
}
|
||||
|
||||
this.groups.push({ enemies, lifeTimeLeft: this.enemyLifeTime });
|
||||
this.waves.push({ enemies, lifeTimeLeft: this.enemyLifeTime });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class EnemyGroupWithLifetime {
|
||||
class EnemyWave {
|
||||
public enemies: Enemy[];
|
||||
public lifeTimeLeft: number;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user