mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +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 {
|
export class WaveEnemySpawner {
|
||||||
private spawnTimer: GameTimer = new GameTimer(5);
|
private spawnTimer: GameTimer = new GameTimer(5);
|
||||||
private groups: EnemyGroupWithLifetime[] = [];
|
private waves: EnemyWave[] = [];
|
||||||
public constructor(
|
public constructor(
|
||||||
private enemySpawner: EnemySpawner,
|
private enemySpawner: EnemySpawner,
|
||||||
private enemiesToSpawn: number,
|
private enemiesToSpawn: number,
|
||||||
@ -24,15 +24,15 @@ export class WaveEnemySpawner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private tryRemoveExpiredEnemies(deltaTime: number): void {
|
private tryRemoveExpiredEnemies(deltaTime: number): void {
|
||||||
for (let i = this.groups.length - 1; 0 <= i; i--) {
|
for (let i = this.waves.length - 1; 0 <= i; i--) {
|
||||||
const group: EnemyGroupWithLifetime = this.groups[i];
|
const wave: EnemyWave = this.waves[i];
|
||||||
group.lifeTimeLeft -= deltaTime;
|
wave.lifeTimeLeft -= deltaTime;
|
||||||
if (group.lifeTimeLeft <= 0) {
|
if (wave.lifeTimeLeft <= 0) {
|
||||||
for (const enemy of group.enemies) {
|
for (const enemy of wave.enemies) {
|
||||||
this.enemySpawner.returnEnemy(enemy);
|
this.enemySpawner.returnEnemy(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.groups.splice(i, 1);
|
this.waves.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,12 +53,12 @@ export class WaveEnemySpawner {
|
|||||||
enemies.push(enemy);
|
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 enemies: Enemy[];
|
||||||
public lifeTimeLeft: number;
|
public lifeTimeLeft: number;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user