import{ setupLevel, setupLevelUi } from './level.js'; function buildLevel(x, y, t, intro) { const ts = t.slice(0, -1); const tf = t[t.length-1]; return setupLevel(ts.map(T => [ x(T), y(T) ]), [ x(tf), y(tf) ], intro); } const levels = { 'initial jump': [ [], setupLevel([], [8, 8], 'please launch the platform into the AMH processor.') ], 'monopole harvesting 0': [ ['initial jump'], setupLevel([[3, 3]], [8,8], 'please ensure that all monopoles are collected before proceeding to the processor.') ], 'monopole harvesting 1': [ ['initial jump'], setupLevel([[4, 2]], [8,4], 'the automated navigation system seems to have overshot on the Y axis. please correct.') ], 'monopole harvesting 2': [ ['initial jump'], setupLevel([[1, 2]], [5,4], 'the automated navigation system seems to have missed the offset on the X axis. please correct.') ], 'inverted': [ ['initial jump'], setupLevel([[-3, -3]], [-8,-8]) ], 'double inverted': [ ['initial jump'], setupLevel([[-8, -8]], [-3,-3]) ], 'parabolic 0': [ ['monopole harvesting'], buildLevel( t => t, t => t**2, [...Array(4).keys()].map(x => x), ), ], 'parabolic 1': [ ['monopole harvesting'], buildLevel(t => t-2, t => t**2 - 2, [...Array(4).keys()].map(x => x)), ], 'parabolic 2': [ ['monopole harvesting'], buildLevel(t => t**2, t => t, [...Array(4).keys()].map(x => x)), ], 'parabolic 3': [ ['monopole harvesting'], buildLevel(t => t-2, t => (t-2)**2, [...Array(4).keys()].map(x => x)), ], 'parabolic 4': [ ['monopole harvesting'], buildLevel(t => -0.5*(t-3)**2+1, t => t-4, [...Array(6).keys()].map(x => x)), ], 'sinusoidal 0': [ ['parabolic 4'], buildLevel(t => Math.sin(t), t => t, [...Array(6).keys()].map(x => 0.5 * Math.PI * x)), ], 'sinusoidal 1': [ ['parabolic 4'], buildLevel(t => t-4, t => 4*Math.sin(t), [...Array(12).keys()].map(x => 0.25 * Math.PI * x)), ], '(co)sinusoidal 2': [ ['parabolic 4'], buildLevel(t => t-4, t => 4*Math.cos(t), [...Array(12).keys()].map(x => 0.25 * Math.PI * x)), ], 'orbital': [ ['(co)sinusoidal 2'], buildLevel(t => 8*Math.cos(t), t => 8*Math.sin(t), [...Array(7).keys()].map(x => 0.25 * Math.PI * (x+1))), ], 'spiral': [ ['orbital'], buildLevel(t => Math.cos(t)*t, t => Math.sin(t)*t, [...Array(8).keys()].map(x => 0.25 * Math.PI * x)), ], }; export function setupLevelSelectUi(root, sfx) { const levelList = document.createElement('ol'); const levelPicker = name => { const [ dependencies, level ] = levels[name]; const allDependenciesSatisfied = dependencies.map(x => levels[x][1].completed).reduce((acc, x) => acc && x, true); // if (allDependenciesSatisfied) { if (true) { sfx.listAppearAudio.currentTime = 0; sfx.listAppearAudio.play(); const button = document.createElement('input'); button.type = 'button'; button.value = name; button.onmouseenter = () => { sfx.buttonEnterAudio.currentTime = 0; sfx.buttonEnterAudio.play(); } button.onclick = () => { sfx.buttonClickAudio.currentTime = 0; sfx.buttonClickAudio.play(); root.innerText = ''; const header = document.createElement('h1'); header.classList.add('centered'); header.innerText = name; root.appendChild(header); setupLevelUi(level, root, sfx); } const li = document.createElement('li'); li.appendChild(button); if (level.completed) { li.appendChild(document.createTextNode('[complete]')); } levelList.appendChild(li); } } let time = 0; [...Object.keys(levels)].forEach(name => { setTimeout(() => { levelPicker(name); }, 100 * time + 100) time += 1; }); const header = document.createElement('h1'); header.classList.add('center'); header.innerText = 'AVAILABLE CONTRACTS'; root.appendChild(header); const p = document.createElement('p'); p.innerText = 'Please select a General Products AMH hyperspace navigation contract from the list below.'; root.appendChild(p); root.appendChild(levelList); }