23 lines
600 B
JavaScript
23 lines
600 B
JavaScript
export default class LevelManager {
|
|
constructor(scene, levelData) {
|
|
this.scene = scene;
|
|
this.levels = levelData; // array of level objects
|
|
this.currentLevel = 1;
|
|
this.currentConfig = this.levels[0];
|
|
}
|
|
|
|
startLevel(num) {
|
|
this.currentLevel = num;
|
|
this.currentConfig = this.levels[num - 1];
|
|
// could broadcast an event for UI if desired
|
|
}
|
|
|
|
levelUp() {
|
|
const next = this.currentLevel + 1;
|
|
if (next <= this.levels.length) {
|
|
this.startLevel(next);
|
|
this.scene.spawnManager.updateSpawnInterval(this.currentConfig.spawnInterval);
|
|
}
|
|
}
|
|
}
|