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>
This commit is contained in:
47
assets/scripts/level/LevelRegistry.ts
Normal file
47
assets/scripts/level/LevelRegistry.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user