blob: a970d9cc003ca6c2704b9f4d3f51f42dad718c4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { LEVELS, Level, LevelNames } from ".";
import { Game } from "..";
import { Player, Portal } from "../entities";
import { Grid, Level as LevelSystem, SystemNames } from "../systems";
export class LevelSelection extends Level {
constructor() {
super(LevelNames.LevelSelection);
}
public init(game: Game): void {
const gridSystem = game.getSystem<Grid>(SystemNames.Grid);
const center = gridSystem.getCenterGrid();
const levelSystem = game.getSystem<LevelSystem>(SystemNames.Level);
const unlocked = levelSystem.getUnlockedLevels();
LEVELS.forEach((level, i) => {
if (
!unlocked.has(level.name) ||
level.name === LevelNames.LevelSelection
) {
return;
}
const portal = new Portal(level.name, { x: i, y: 7 });
game.addEntity(portal);
});
const player = new Player(center);
game.addEntity(player);
}
}
|