diff --git a/app.js b/app.js
index 4bedb28..2fbc9b2 100644
--- a/app.js
+++ b/app.js
@@ -8,7 +8,7 @@ const state = { mode: 'mainline', level: null, revision: '', baseline: '', defin
const images = new Map();
const canvas = $('board'), ctx = canvas.getContext('2d');
let transform = null, validateTimer;
-const layoutText = level => JSON.stringify([level.width, level.height, level.characters, level.aoes]);
+const layoutText = level => JSON.stringify([level.width, level.height, level.characters, level.aoes, level.levelSettings]);
const dirty = () => state.level && layoutText(state.level) !== state.baseline;
const sameSelection = (a, b) => a?.collection === b?.collection && a?.index === b?.index;
const selections = () => !state.selected ? [] : state.selections?.includes(state.selected) ? state.selections : [state.selected];
@@ -151,7 +151,7 @@ function render() {
$('view-state').textContent = state.view === 'source' ? (state.material ? '放置 · ' + state.material.name : '源布局') : '局内预览 · 只读';
$('zoom-label').textContent = Math.round(state.zoom * 100) + '%';
$('draft-actions').hidden = !state.draft;
- renderInspector(); draw();
+ renderInspector(); renderLevelProperties(); draw();
}
function draftSave() {
try {
@@ -212,6 +212,8 @@ async function openLevel(number) {
try {
const result = await api('/api/levels/' + number);
state.level = result.level; state.sourceLevel = result.sourceLevel; state.revision = result.revision; state.baseline = layoutText(result.level); state.result = result;
+ state.levelBaseSettings = result.effectiveSettings ? clone(result.effectiveSettings) : null;
+ state.templateSource = result.templateSource;
state.history = []; state.future = []; state.selected = null; state.material = null; state.drag = null;
state.view = 'source'; state.zoom = 1; state.pan = { x: 0, y: 0 }; state.draft = null;
try { const draft = JSON.parse(localStorage.getItem(draftKey())); if (draft?.level && layoutText(draft.level) !== state.baseline) { draft.level.displayLevel = number; state.draft = draft; } }
@@ -236,7 +238,7 @@ async function validate() {
$('validation-status').textContent = '正在校验';
const result = await api('/api/validate', { level });
if (sequence !== state.sequence) return;
- state.result = result; showValidation(result); $('scene').textContent = result.scene || '-'; refreshExtraEffective(); draw();
+ state.result = result; showValidation(result); $('scene').textContent = result.scene || '-'; refreshExtraEffective(); renderLevelProperties(); draw();
return result;
}
function scheduleValidation() { clearTimeout(validateTimer); $('validation-status').textContent = '待校验'; validateTimer = setTimeout(guarded(validate), 300); }
@@ -724,7 +726,7 @@ $('restore-draft').onclick = guarded(() => {
const before = clone(state.level);
// 草稿保留原始版本号,磁盘已变化时仍由保存接口拦截覆盖。
state.level = { ...state.level, width: draft.level.width, height: draft.level.height,
- characters: draft.level.characters, aoes: draft.level.aoes };
+ characters: draft.level.characters, aoes: draft.level.aoes, levelSettings: draft.level.levelSettings };
state.revision = draft.revision; state.draft = null; state.view = 'source'; changed(before); message('已恢复本地草稿');
});
$('discard-draft').onclick = () => { if (confirm('删除此关卡的本地草稿?')) { localStorage.removeItem(draftKey()); state.draft = null; render(); } };
@@ -802,6 +804,7 @@ new ResizeObserver(draw).observe($('viewport'));
guarded(async () => {
icons();
const bootstrap = await api('/api/bootstrap'); Object.assign(state, bootstrap);
+ initLevelProperties();
$('project-path').textContent = bootstrap.project; $('project-path').title = bootstrap.project;
$('level-total').textContent = '/ ' + bootstrap.levelCount; $('level-number').max = bootstrap.levelCount;
await openLevel(Number(new URLSearchParams(location.search).get('level') || 1));
diff --git a/level-properties.js b/level-properties.js
new file mode 100644
index 0000000..2e68168
--- /dev/null
+++ b/level-properties.js
@@ -0,0 +1,91 @@
+'use strict';
+function currentLevelSettings() {
+ return clone(state.level.levelSettings || state.result?.effectiveSettings || state.levelBaseSettings || state.settingsCatalog.records[state.sourceLevel]);
+}
+function levelSettingsSummary(settings) {
+ const options = state.settingsCatalog, e = settings.encounter;
+ const name = (items, id) => items.find(item => item.id === id)?.name || String(id);
+ return '场景:' + name(options.scenes, e.sceneId) + ' · Boss:' + name(options.monsters, e.bossId) + '\n小怪:' + e.monsterIds.map(id => name(options.monsters, id)).join('、') + ' · 难度:' + options.tiers[settings.difficulty.effectiveDifficultyId];
+}
+function levelEnemyChoices(options, sceneId, displayLevel, type) {
+ return options.monsters.filter(item => item.type === type).map(item => {
+ const reasons = [];
+ if (!item.resourceReady) reasons.push('资源不可用');
+ if (item.unlockLevel > displayLevel) reasons.push('第 ' + item.unlockLevel + ' 关解锁');
+ if (!item.sceneIds.includes(sceneId)) {
+ const scenes = item.sceneIds.map(id => options.scenes.find(scene => scene.id === id)?.name || String(id));
+ reasons.push('适用场景:' + (scenes.join('、') || '无'));
+ }
+ return { ...item, disabled: reasons.length > 0, name: item.name + (reasons.length ? '(' + reasons.join(';') + ')' : '') };
+ });
+}
+function renderLevelProperties() {
+ if (!state.settingsCatalog || !state.level) return;
+ const mainline = state.mode !== 'ghost-king', open = mainline && state.propertyView === 'level';
+ $('level-properties').hidden = !open; $('object-properties-panel').hidden = open;
+ document.querySelector('[data-properties="level"]').disabled = !mainline;
+ document.querySelectorAll('[data-properties]').forEach(button => button.classList.toggle('active', button.dataset.properties === (open ? 'level' : 'object')));
+ if (!open) return;
+ const options = state.settingsCatalog, value = currentLevelSettings(), e = value.encounter, d = value.difficulty;
+ const fill = (id, items, selected) => {
+ const select = $(id); select.replaceChildren();
+ for (const item of items) {
+ const option = new Option(item.name + ' · ' + item.id, item.id);
+ option.disabled = Boolean(item.disabled);
+ select.add(option);
+ }
+ select.value = selected;
+ };
+ fill('level-scene', options.scenes.filter(item => item.resourceReady && item.editorReady !== false), e.sceneId);
+ const enemies = type => levelEnemyChoices(options, e.sceneId, state.level.displayLevel, type);
+ fill('level-boss', enemies(2), e.bossId);
+ fill('level-tier', Object.entries(options.tiers).map(([id, name]) => ({ id, name })), d.effectiveDifficultyId);
+ $('level-minions').replaceChildren();
+ for (const item of enemies(1)) {
+ const label = document.createElement('label'), checkbox = document.createElement('input');
+ checkbox.type = 'checkbox'; checkbox.value = item.id; checkbox.checked = e.monsterIds.includes(item.id);
+ checkbox.dataset.unavailable = String(item.disabled);
+ label.classList.toggle('enemy-unavailable', item.disabled);
+ checkbox.onchange = guarded(() => editLevelSettings(settings => {
+ settings.encounter.monsterIds = Array.from($('level-minions').querySelectorAll('input:checked'), input => Number(input.value));
+ }));
+ const caption = document.createElement('span'); caption.textContent = item.name + ' · ' + item.id;
+ label.append(checkbox, caption); $('level-minions').append(label);
+ }
+ for (const [id, key] of levelSettingsNumbers) $(id).value = d[key];
+ $('level-template').textContent = '来源 ID:' + state.sourceLevel + ' · 模板来源:' + (state.templateSource ?? state.sourceLevel) + (state.level.levelSettings ? ' · 独立配置' : ' · 项目配置');
+ const balance = state.result?.board?.combatBalance;
+ const values = balance ? [['Boss 血量', balance.bossHp], ['小怪基础血量', balance.minionHpUnit], ['小怪初始血量倍率', balance.initialMinionHpMultiplier], ['小怪初始血量', balance.initialMinionHp], ['小怪移动速度', d.monsterMoveSpeed], ['目标战斗时长', d.targetLeaderTime + ' 秒']] : [];
+ $('level-effective').replaceChildren();
+ for (const [label, value] of values) {
+ const dt = document.createElement('dt'), dd = document.createElement('dd'); dt.textContent = label; dd.textContent = value ?? '-'; $('level-effective').append(dt, dd);
+ }
+ $('level-progression').textContent = JSON.stringify(state.level.progression || {}, null, 2);
+ $('level-settings-note').textContent = state.result?.issues?.length ? '配置未通过校验,请查看棋盘下方问题列表。' : balance ? '' : '等待校验生效数值';
+ $('level-settings-form').querySelectorAll('input,select').forEach(input => { input.disabled = state.busy || state.view !== 'source' || input.dataset.unavailable === 'true'; });
+}
+const levelSettingsNumbers = [['level-boss-hp', 'bossHp'], ['level-minion-hp', 'minionHpMultiplier'], ['level-speed', 'monsterMoveSpeed'], ['level-target-time', 'targetLeaderTime'], ['level-seed', 'minionGroupSeed']];
+function editLevelSettings(action) {
+ if (state.busy || state.mode === 'ghost-king' || state.view !== 'source') return;
+ try {
+ const settings = currentLevelSettings(); action(settings);
+ MainlineWorkspace.settings.resolve(settings, settings, state.settingsCatalog);
+ mutate(() => { state.level.levelSettings = settings; });
+ } catch (error) { renderLevelProperties(); throw error; }
+}
+function initLevelProperties() {
+ document.querySelectorAll('[data-properties]').forEach(button => { button.onclick = () => { state.propertyView = button.dataset.properties; render(); }; });
+ $('level-settings-form').onsubmit = event => event.preventDefault();
+ $('level-scene').onchange = guarded(() => editLevelSettings(settings => {
+ const sceneId = Number($('level-scene').value), available = state.settingsCatalog.monsters.filter(item => item.resourceReady && item.sceneIds.includes(sceneId) && item.unlockLevel <= state.level.displayLevel);
+ const boss = available.find(item => item.type === 2);
+ const minions = available.filter(item => item.type === 1);
+ if (!boss || !minions.length) throw new Error('当前关卡尚无可用的该场景 Boss 或小怪');
+ settings.encounter = { sceneId, bossId: available.some(item => item.id === settings.encounter.bossId) ? settings.encounter.bossId : boss.id,
+ monsterIds: settings.encounter.monsterIds.filter(id => minions.some(item => item.id === id)) };
+ if (!settings.encounter.monsterIds.length) settings.encounter.monsterIds = minions.map(item => item.id);
+ }));
+ $('level-boss').onchange = guarded(() => editLevelSettings(settings => { settings.encounter.bossId = Number($('level-boss').value); }));
+ $('level-tier').onchange = guarded(() => editLevelSettings(settings => { settings.difficulty.effectiveDifficultyId = Number($('level-tier').value); }));
+ for (const [id, key] of levelSettingsNumbers) $(id).onchange = guarded(() => editLevelSettings(settings => { settings.difficulty[key] = Number($(id).value); }));
+}
diff --git a/level-settings.js b/level-settings.js
new file mode 100644
index 0000000..43a8ec2
--- /dev/null
+++ b/level-settings.js
@@ -0,0 +1,34 @@
+(function (root) {
+ 'use strict';
+ const copy = value => JSON.parse(JSON.stringify(value));
+ const difficultyFields = ['effectiveDifficultyId', 'computedDifficultyId', 'bossHp', 'minionHpMultiplier', 'minionGroupSeed', 'targetLeaderTime', 'monsterMoveSpeed', 'twoStarDamageRatio', 'threeStarDamageRatio', 'minionHpUnit', 'minionHpStageOffsets'];
+ function resolve(input, baseline, options) {
+ if (!baseline) throw new Error('关卡配置模板不存在');
+ const value = copy(input === undefined ? baseline : input);
+ if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key => !['encounter', 'difficulty'].includes(key))) throw new Error('关卡属性格式无效');
+ const e = value.encounter, d = value.difficulty;
+ if (!e || Object.keys(e).some(key => !['sceneId', 'bossId', 'monsterIds'].includes(key))) throw new Error('敌人配置格式无效');
+ const scene = options.scenes.find(item => item.id === e.sceneId && item.resourceReady && item.editorReady !== false);
+ if (!scene) throw new Error('场景不存在或资源未就绪');
+ const enemy = (id, type) => {
+ const found = options.monsters.find(item => item.id === id && item.type === type && item.resourceReady);
+ if (!found) throw new Error((type === 2 ? 'Boss' : '小怪') + '不存在或资源未就绪:' + id);
+ if (!found.sceneIds.includes(e.sceneId)) throw new Error(found.name + '不支持场景“' + scene.name + '”');
+ };
+ enemy(e.bossId, 2);
+ if (!Array.isArray(e.monsterIds) || !e.monsterIds.length || new Set(e.monsterIds).size !== e.monsterIds.length) throw new Error('至少选择一种小怪,且不能重复');
+ e.monsterIds.forEach(id => enemy(id, 1));
+ if (!d || Object.keys(d).some(key => !difficultyFields.includes(key))) throw new Error('难度配置字段无效');
+ for (const key of ['effectiveDifficultyId', 'computedDifficultyId']) if (!Number.isInteger(d[key]) || !options.tiers[d[key]]) throw new Error('难度档位无效');
+ for (const key of ['bossHp', 'minionHpMultiplier', 'targetLeaderTime', 'monsterMoveSpeed']) if (!Number.isFinite(d[key]) || d[key] <= 0) throw new Error('战斗参数必须大于零:' + key);
+ if (d.minionHpUnit !== undefined && (!Number.isFinite(d.minionHpUnit) || d.minionHpUnit <= 0)) throw new Error('小怪基础血量必须大于零');
+ if (!Number.isSafeInteger(d.minionGroupSeed) || d.minionGroupSeed < 0) throw new Error('小怪编队种子必须是非负整数');
+ for (const key of ['twoStarDamageRatio', 'threeStarDamageRatio']) if (!Number.isFinite(d[key]) || d[key] < 0 || d[key] > 1) throw new Error('星级伤害比例必须在 0 到 1 之间');
+ if (d.twoStarDamageRatio > d.threeStarDamageRatio) throw new Error('二星伤害比例不能大于三星');
+ if (d.minionHpStageOffsets !== undefined && (!Array.isArray(d.minionHpStageOffsets) || d.minionHpStageOffsets.length < 2 || d.minionHpStageOffsets[0] !== 0 || d.minionHpStageOffsets.some(v => !Number.isSafeInteger(v) || v < 0))) throw new Error('小怪血量阶段偏移无效');
+ return value;
+ }
+ const api = { resolve };
+ if (typeof module !== 'undefined' && module.exports) module.exports = api;
+ else root.LevelSettings = api;
+})(globalThis);
diff --git a/mainline.js b/mainline.js
index d06b1a1..40f5fd9 100644
--- a/mainline.js
+++ b/mainline.js
@@ -28,6 +28,7 @@
'' +
'
' +
'
' +
+ '' +
'' +
'' +
'
' +
@@ -47,6 +48,10 @@
requestAnimationFrame(() => { if (dialog.open) list.selectedOptions[0]?.scrollIntoView({ block: 'nearest' }); });
$('mainline-pending').textContent = modified ? '待应用' : '已同步'; $('mainline-target').max = draft.order.length;
const index = draft.order.indexOf(selected);
+ if (index >= 0) {
+ const settings = draft.levels[index].levelSettings || state.settingsCatalog.records[draft.templates[selected]];
+ $('mainline-config-summary').textContent = '配置模板:第 ' + (index + 1) + ' 关 · 来源 ' + selected + '\n' + levelSettingsSummary(settings);
+ }
$('mainline-up').disabled = index <= 0; $('mainline-down').disabled = index < 0 || index === draft.order.length - 1;
$('mainline-remove').disabled = index < 0 || draft.order.length <= 1;
const importing = $('mainline-kind').value === 'json';
@@ -70,6 +75,7 @@
const index = draft.order.indexOf(selected); if (index < 0) throw new Error('请先选择模板关卡');
const id = Math.max(...MainlineWorkspace.sourceOrder(draft)) + 1;
let level = clone(draft.levels[index]);
+ if (!confirm('新关卡将继承以下配置:\n' + $('mainline-config-summary').textContent + '\n\n是否继续新增?')) return;
if ($('mainline-kind').value === 'json') {
if (readingFile || !importedLayout) throw new Error('请先选择单关 JSON 文件');
level = { ...level, ...clone(importedLayout) };
diff --git a/offline.js b/offline.js
index 20cd03c..bb9e81a 100644
--- a/offline.js
+++ b/offline.js
@@ -2,6 +2,7 @@
'use strict';
const data = JSON.parse(document.getElementById('offline-data').textContent);
const extraFields = window.LevelExtraFields;
+const levelSettings = window.MainlineWorkspace.settings, settingsOptions = data.settingsCatalog;
const factories = {"assets/Logic/Scripts/YnykContentConfig.ts":function(module,exports,load){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
@@ -2335,6 +2336,8 @@ const adapter = load("assets/Logic/Scripts/LevelAdapter.ts"), optimizer = load("
const byId = new Map(data.definitions.map(item=>[item.id,item]));
const basePosition = new Map(data.sourceOrder.map((id,index)=>[id,index]));
const sceneFor = number => data.sceneRoutes[data.routeByLevel[basePosition.get(templateOrder[number-1])]];
+const sceneForId = id => data.routesByScene[id];
+const settingsFor = number => settingsOptions.records[templateOrder[number-1]];
function configure(nextOrder, templates, archivedLevels = {}) {
order = [...nextOrder,...Object.keys(archivedLevels).map(Number).sort((a,b)=>a-b)]; templateOrder = order.map(id=>templates[id]);
const records = source => Object.fromEntries(templateOrder.map((id,index)=>[index+1,source[basePosition.get(id)+1]]));
@@ -2342,9 +2345,10 @@ function configure(nextOrder, templates, archivedLevels = {}) {
const sources = Object.fromEntries(order.map(id=>[id,data.sourceTemplates[templates[id]] ?? templates[id]]));
const unlocks = entries => entries.map(entry=>({...entry,...(entry.unlockLevel ? {unlockLevel:load("assets/Framework/Scripts/MainlineLevelOrder.ts").mapMainlineUnlockLevel(entry.unlockLevel,nextOrder,sources)} : {})}));
catalog = catalogFactory({...data.config,artifacts:unlocks(data.config.artifacts),mechanisms:unlocks(data.config.mechanisms)},{...data.monsters,monsters:unlocks(data.monsters.monsters)},data.scenes,{...data.encounters,levels:records(data.encounters.levels)});
+ settingsOptions.monsters = catalog.monsters;
}
configure(data.order,Object.fromEntries(data.sourceOrder.map(id=>[id,id])),data.archivedLevels);
-function validate(level, sourceOnly = false) {
+function validate(level, sourceOnly = false, encounterContext) {
const issues = [];
const add = (message, collection, entryIndex) => issues.push({ message, collection, entryIndex });
if (!level || !Number.isInteger(level.displayLevel) || level.displayLevel < 1 || level.displayLevel > order.length) {
@@ -2380,14 +2384,22 @@ function validate(level, sourceOnly = false) {
}
});
}
- if (issues.length || sourceOnly) return { issues, board: null };
try {
- const scene = sceneFor(level.displayLevel);
- const adapted = adapter.adaptLevel(copy(level), catalog, {
- routeData: scene.routeData, difficultyConfig: difficulty, boardRotationOffsetDeg: scene.rotation,
+ const effectiveSettings = levelSettings.resolve(level.levelSettings, settingsFor(level.displayLevel), settingsOptions);
+ if (level.levelSettings) for (const id of [effectiveSettings.encounter.bossId, ...effectiveSettings.encounter.monsterIds]) {
+ const enemy = catalog.getMonster(id);
+ const unlockLevel = encounterContext?.unlocks[id] ?? enemy.unlockLevel;
+ if (unlockLevel > (encounterContext?.displayLevel ?? level.displayLevel)) throw new Error(enemy.name + '尚未在当前关卡解锁(第 ' + unlockLevel + ' 关)');
+ }
+ if (issues.length || sourceOnly) return { issues, board: null, effectiveSettings };
+ const scene = sceneForId(effectiveSettings.encounter.sceneId);
+ const activeCatalog = Object.create(catalog); activeCatalog.getEncounter = () => effectiveSettings.encounter;
+ const activeDifficulty = { ...difficulty, levels: { ...difficulty.levels, [level.displayLevel]: effectiveSettings.difficulty } };
+ const adapted = adapter.adaptLevel(copy(level), activeCatalog, {
+ routeData: scene.routeData, difficultyConfig: activeDifficulty, boardRotationOffsetDeg: scene.rotation,
});
const board = optimizer.optimizeLevel(adapted, scene.routeData);
- return { issues, board, scene: scene.name, boundary: scene.routeData.walkable_area.inner_boundary };
+ return { issues, board, scene: scene.name, boundary: scene.routeData.walkable_area.inner_boundary, effectiveSettings };
} catch (error) {
add('游戏布局适配失败:' + error.message);
return { issues, board: null };
@@ -2400,7 +2412,7 @@ window.offlineEditor = { data, validate, copy, configure, adaptGhost: load("asse
const { data, validate, copy, configure } = window.offlineEditor;
const model = window.MainlineWorkspace;
const key = 'offline-level-editor:' + data.rulesVersion + ':' + data.dataVersion;
- const layout = level => JSON.stringify([level.width, level.height, level.characters, level.aoes]);
+ const layout = level => JSON.stringify([level.width, level.height, level.characters, level.aoes, level.levelSettings]);
let workspace = model.create(data), revisions = {}, storedText, storageError = '';
const activate = value => configure(value.order, value.templates, value.archivedLevels);
function ghostLevel(number, value = workspace) {
@@ -2450,7 +2462,7 @@ window.offlineEditor = { data, validate, copy, configure, adaptGhost: load("asse
} catch (error) { workspace = model.create(data); storageError = '未恢复本机工作区:' + error.message; }
activate(workspace);
window.offlineEditor.api = async (url, body) => {
- if (url === '/api/bootstrap') return { project: '离线工作区-' + data.dataVersion, levelCount: workspace.order.length, ghostCount: data.ghostSources.length, definitions: data.definitions };
+ if (url === '/api/bootstrap') return { project: '离线工作区-' + data.dataVersion, levelCount: workspace.order.length, ghostCount: data.ghostSources.length, definitions: data.definitions, settingsCatalog: data.settingsCatalog };
if (url === '/api/validate') return validate(body.level);
if (url === '/api/ghost-validate') return validateGhost(body.level);
const ghostMatch = /^\/api\/ghost-levels\/(\d+)$/.exec(url);
@@ -2518,7 +2530,7 @@ window.offlineEditor = { data, validate, copy, configure, adaptGhost: load("asse
revisions.mainline = (revisions.mainline || 0) + 1;
}
const level = copy(workspace.levels[number - 1]);
- return { level, revision: String(revisions[id] || 0), sourceLevel: id,
+ return { level, revision: String(revisions[id] || 0), sourceLevel: id, templateSource: data.sourceTemplates[workspace.templates[id]] ?? workspace.templates[id],
...validate(level), backup: '本机浏览器工作区;交付请导出完整数据包' };
};
document.addEventListener('DOMContentLoaded', () => {
diff --git a/project-files.js b/project-files.js
index a381737..9d89973 100644
--- a/project-files.js
+++ b/project-files.js
@@ -20,7 +20,12 @@
};
const inventory = model.sourceOrder(bundle), count = inventory.length;
if (index.chunkSize !== 50 || count > 20000) throw new Error('项目分块规格不受支持');
- const byId = new Map(inventory.map(id => [id, { ...model.sourceLevel(bundle, id), displayLevel: id }]));
+ const byId = new Map(inventory.map(id => {
+ const source = { ...model.sourceLevel(bundle, id), displayLevel: id };
+ // 游戏以敌人、难度文件为唯一来源,避免分块中残留另一份过期配置。
+ delete source.levelSettings;
+ return [id, source];
+ }));
const chunks = [];
for (let first = 1; first <= count; first += index.chunkSize) {
const chunkId = String(chunks.length + 1).padStart(3, '0'), last = Math.min(count, first + index.chunkSize - 1);
@@ -41,6 +46,11 @@
encounters.levels[id] = JSON.parse(JSON.stringify(encounters.levels[template]));
templates[id] = data.sourceTemplates[template] ?? template;
}
+ for (const id of inventory) {
+ const settings = model.sourceLevel(bundle, id).levelSettings;
+ if (!settings) continue;
+ encounters.levels[id] = settings.encounter; difficulty.levels[id] = settings.difficulty;
+ }
difficulty.levelCount = count;
scheduleJson(directory + 'MainlineDifficulty.json', difficulty);
scheduleJson(directory + 'MainlineEncounterConfig.json', encounters);
diff --git a/style.css b/style.css
index af67cc4..6abb353 100644
--- a/style.css
+++ b/style.css
@@ -65,3 +65,5 @@ header { flex-wrap: wrap; }
@media (max-width: 600px) { dialog#mainline-dialog { padding: 14px; } #mainline-list { height: 240px; } .file-actions { flex-wrap: wrap; } }
#selection-help{position:absolute;right:16px;bottom:12px;max-width:calc(100% - 32px);padding:6px 9px;border:1px solid #dce1e6;border-radius:4px;background:rgba(255,255,255,.94);color:#64727c;font-size:11px;line-height:1.7;pointer-events:none;overflow-wrap:anywhere}#selection-help span{display:block}
#selection-help{white-space:pre-line}
+#property-tabs{margin-bottom:18px}#level-properties h2{font-size:14px}#level-properties fieldset{border:0;padding:0;margin:16px 0}#level-minions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}#level-minions label{display:flex;align-items:center;gap:6px;margin:0}#level-minions input{width:16px;height:16px;margin:0}#level-properties pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}#level-properties details{margin:16px 0}.settings-muted{font-size:12px;color:#64727c;line-height:1.6}.settings-effective{border-top:1px solid #dce1e6;padding-top:14px}#mainline-config-summary{white-space:pre-line;font-size:13px;line-height:1.8;margin:12px 0}
+#level-settings-form{display:flex;flex-direction:column;gap:12px;margin-top:12px}#level-minions label{flex-direction:row;justify-content:flex-start;overflow-wrap:anywhere;line-height:1.5}#level-minions input{flex-shrink:0}#level-minions .enemy-unavailable{color:#737b83;cursor:not-allowed}#level-minions label span{min-width:0}#level-effective{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);margin-top:10px;line-height:1.6}#level-settings-form details>label{margin-top:12px}
diff --git a/workspace.js b/workspace.js
index bff910f..bbe0dff 100644
--- a/workspace.js
+++ b/workspace.js
@@ -2,6 +2,7 @@
'use strict';
const copy = value => JSON.parse(JSON.stringify(value));
const fields = ['width', 'height', 'characters', 'aoes'];
+ const settings = typeof module !== 'undefined' && module.exports ? require('./level-settings.cjs') : root.LevelSettings;
function importLayout(input) {
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new Error('请选择有效的单关 JSON 对象');
if (input.formatVersion !== undefined || Array.isArray(input.levels)) throw new Error('请选择导出的单关 JSON,不是完整关卡数据包');
@@ -43,15 +44,16 @@
result.templates[id] = template;
const original = base.get(template);
if (!incoming || (active && incoming.displayLevel !== number) || fields.some(field => incoming[field] === undefined)) throw new Error('显示编号或布局字段无效:' + number);
- // 只接收布局字段;来源、难度与玩法元数据不能由数据包任意覆盖。
- return { ...copy(original), ...(base.has(id) ? {} : { sourceId: 'editor_level_' + id, sourcePath: 'editor/level_' + id + '.json', sourceUuid: 'editor_level_' + id }),
+ // 布局与经过白名单校验的关卡属性可编辑,来源及特殊玩法继续继承模板。
+ const levelSettings = incoming.levelSettings === undefined ? {} : { levelSettings: settings.resolve(incoming.levelSettings, data.settingsCatalog.records[template], data.settingsCatalog) };
+ return { ...copy(original), ...levelSettings, ...(base.has(id) ? {} : { sourceId: 'editor_level_' + id, sourcePath: 'editor/level_' + id + '.json', sourceUuid: 'editor_level_' + id }),
...Object.fromEntries(fields.map(field => [field, copy(incoming[field])])), displayLevel: number };
}
result.levels = order.map((id, index) => normalizeLevel(id, input.levels[index], index + 1, true));
result.archivedLevels = Object.fromEntries(Object.entries(archive).map(([id, level]) => [id, normalizeLevel(Number(id), level, Number(id), false)]));
return result;
}
- const api = { create, normalize, sourceOrder, sourceLevel, importLayout };
+ const api = { create, normalize, sourceOrder, sourceLevel, importLayout, settings };
if (typeof module !== 'undefined' && module.exports) module.exports = api;
else root.MainlineWorkspace = api;
})(globalThis);
diff --git a/使用说明.md b/使用说明.md
index 2560752..09fc248 100644
--- a/使用说明.md
+++ b/使用说明.md
@@ -2,6 +2,14 @@
将整个文件夹解压到本机,双击 `编辑器.html`,使用 Chrome 或 Edge 打开。无需安装 Cocos、Node.js,也不需要网络或游戏项目。
+## 主线关卡属性
+
+Boss 和小怪列表展示所有已配置的敌人。不符合当前关卡条件的条目置灰,不可选择,并标注解锁关数、适用场景或资源不可用等原因;调整关卡顺序或场景后会重新判断。
+
+在右侧切换“关卡属性”,可修改场景、Boss、小怪组合、难度档位及展开后的战斗参数。至少保留一种小怪,敌人必须符合场景和解锁条件;校验失败不能保存或交付。仅显示资源与棋盘边界完整的场景。难度档位与战斗数值独立,切换档位不自动重算血量。面板下方显示游戏适配后的生效数值和只读特殊玩法配置,逐鹿不开放此项编辑。
+
+新增主线关卡先确认模板配置摘要,再新增并按需修改属性。存本机、完整数据包及项目文件包均保留这些属性;单关 JSON 导入只读取棋盘,不会覆盖关卡属性。交付前导出项目文件包,程序应用后需重启游戏预览并验收,不会热更新运行中的游戏。
+
## 文件操作
- 上传箭头:导入单关 JSON,应用到当前关卡,仅替换布局。
diff --git a/编辑器.html b/编辑器.html
index ef0b67b..d88bc63 100644
--- a/编辑器.html
+++ b/编辑器.html
@@ -1,6 +1,6 @@
-关卡编辑器
+关卡编辑器
关卡编辑器
@@ -10,6 +10,7 @@