monsterplex/src/data/levels/index.js

66 lines
2.6 KiB
JavaScript

import level01 from './level01.js';
import level02 from './level02.js';
import level03 from './level03.js';
import level04 from './level04.js';
import level05 from './level05.js';
import level06 from './level06.js';
import level07 from './level07.js';
import level08 from './level08.js';
import level09 from './level09.js';
import level10 from './level10.js';
import level11 from './level11.js';
// Campaigns group levels into themed "maps" for the level select screen.
// Each campaign gets its own background art (bgKey), menu theme music
// (musicKey), and in-level look (data/themes.js), so adding a new campaign
// is: create its levels, add a bg image + manifest entry, add an entry to
// THEMES, add a row here. Node positions are in 960x540 design units (NOT multiplied by
// WORLD_SCALE - the scene scales them), and the path is rendered as a line
// through them in order. `positions` may be omitted to auto-place the
// campaign's levels: a 2-lane circuit (top lane right->left, bottom lane
// left->right, finish flag bottom-right) that comfortably fits up to ~12
// levels (see positioning.js). Give explicit `positions` only when you want
// a custom layout - the auto-layout keeps every node in the open band of
// the background art (y roughly 268-412) and clear of the title plate and
// bottom chrome.
export const CAMPAIGNS = [
{
id: 'campaign01',
name: 'Evergreen Lake',
bgKey: 'campaign01_bg',
levels: [level01, level02, level03, level04, level05, level06, level07, level08, level09, level10],
},
{
id: 'campaign02',
name: 'Underprivileged Community',
bgKey: 'campaign02_bg',
// Menu music for this campaign's map in LevelSelect (util/music.js
// playMenuTrack); undefined = the main title theme.
musicKey: 'urban_trap_theme',
// Its old levels (level04-06) moved into campaign01 while it grows toward
// 10; add campaign02's own levels here as they're built. An empty
// campaign renders as a bare map with "0/0 cleared" - fine as scaffolding.
levels: [level11],
},
];
export const LEVELS = CAMPAIGNS.flatMap((c) => c.levels);
export function getLevelById(id) {
return LEVELS.find((level) => level.id === id);
}
export function getCampaignById(id) {
return CAMPAIGNS.find((c) => c.id === id);
}
export function getCampaignOfLevel(levelId) {
return CAMPAIGNS.find((c) => c.levels.some((l) => l.id === levelId)) || null;
}
export function getNextLevelId(id) {
const index = LEVELS.findIndex((level) => level.id === id);
if (index === -1 || index === LEVELS.length - 1) return null;
return LEVELS[index + 1].id;
}