Files
cocos/assets/scripts/level/LevelRegistry.ts
刘宇飞 cba5105908 Initial Cocos Creator port of main-site Unity WebGL game.
Includes core gameplay, 600 exported levels, visual assets, web bridge, and bootstrap scene.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 14:57:46 +08:00

48 lines
1.4 KiB
TypeScript

import { Direction } from '../core/Define';
import { LevelConfig } from './LevelTypes';
import { LEVELS_600 } from './levels-600.generated';
/** 额外关卡(多人等) */
const EXTRA_LEVELS: Record<number, LevelConfig> = {
601: {
levelID: 601,
boundary: { x: 20, y: 20 },
spawns: [
{ x: 0, y: 0, kind: 'player', playerDirection: Direction.North },
{ x: 6, y: 6, kind: 'prop' },
{ x: -1, y: 2, kind: 'prop' },
],
},
999001: {
levelID: 999001,
boundary: { x: 999, y: 999 },
spawns: [
{ x: -9, y: -9, kind: 'player', playerDirection: Direction.South },
{ x: 9, y: 9, kind: 'player', playerDirection: Direction.North },
{ x: -9, y: -10, kind: 'vehicle', vehicleDirection: Direction.North },
{ x: 9, y: 10, kind: 'vehicle', vehicleDirection: Direction.South },
],
},
};
const allLevels: Record<number, LevelConfig> = {
...LEVELS_600,
...EXTRA_LEVELS,
};
export function getLevelConfig(levelID: number): LevelConfig | null {
return allLevels[levelID] ?? null;
}
export function hasLevel(levelID: number): boolean {
return levelID in allLevels;
}
export function registerLevel(config: LevelConfig) {
allLevels[config.levelID] = config;
}
export function getLevelCount(): number {
return Object.keys(allLevels).length;
}