187 lines
10 KiB
C#
187 lines
10 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using EerieVillage.Map.Data;
|
|
using EerieVillage.Map.Generation;
|
|
using EerieVillage.Map.Runtime;
|
|
|
|
namespace EerieVillage.Map.EditorScripts
|
|
{
|
|
/// <summary>
|
|
/// BT13-Dev-Map Phase 2-C — Unity Editor Window 영역 미리보기.
|
|
/// spec §10 정합. PD 결정 §15-11 옵션 12종 모두 노출.
|
|
/// 메뉴: EerieVillage/Map/Preview
|
|
/// </summary>
|
|
public class MapPreviewWindow : EditorWindow
|
|
{
|
|
[MenuItem("EerieVillage/Map/Preview")]
|
|
public static void Open()
|
|
{
|
|
var w = GetWindow<MapPreviewWindow>("Map Preview");
|
|
w.minSize = new Vector2(640, 480);
|
|
w.Show();
|
|
}
|
|
|
|
MapGenerationConfig config;
|
|
MapBlueprint currentBlueprint;
|
|
Vector2 previewScroll;
|
|
Vector2 inspectorScroll;
|
|
float zoom = 1f;
|
|
bool showJumpReach = false;
|
|
bool advancedOptionsExpanded = false;
|
|
|
|
void OnGUI()
|
|
{
|
|
EditorGUILayout.LabelField("BT13-Dev-Map Preview", EditorStyles.boldLabel);
|
|
EditorGUILayout.Space(4);
|
|
|
|
// ─────────── Config 영역 ───────────
|
|
EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
config = (MapGenerationConfig)EditorGUILayout.ObjectField("Config", config,
|
|
typeof(MapGenerationConfig), false);
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
EditorGUILayout.Space(2);
|
|
|
|
// ─────────── 옵션 12종 (§15-11 PD 결정 — 모두 노출) ───────────
|
|
if (config != null)
|
|
{
|
|
inspectorScroll = EditorGUILayout.BeginScrollView(inspectorScroll, GUILayout.Height(220));
|
|
using (new EditorGUI.IndentLevelScope())
|
|
{
|
|
EditorGUI.BeginChangeCheck();
|
|
|
|
// [1] 맵 길이 (Tile)
|
|
config.lengthTiles = EditorGUILayout.IntSlider("Length (Tile)", config.lengthTiles, 20, 500);
|
|
|
|
EditorGUILayout.LabelField("거점 영역 (§15-5 OVERRIDE 공중 발판 허용)", EditorStyles.miniBoldLabel);
|
|
// [2-4]
|
|
config.spawnDensity = EditorGUILayout.Slider("Spawn Density", config.spawnDensity, 0f, 1f);
|
|
config.minSpawnSpacingTiles = EditorGUILayout.IntSlider("Min Spawn Spacing", config.minSpawnSpacingTiles, 2, 30);
|
|
config.maxSpawnPerMap = EditorGUILayout.IntSlider("Max Spawn Per Map", config.maxSpawnPerMap, 0, 32);
|
|
config.allowFloatingSpawnPoints = EditorGUILayout.Toggle("Allow Floating Spawn (§15-5)", config.allowFloatingSpawnPoints);
|
|
|
|
EditorGUILayout.LabelField("발판 영역 (§6 룰·이중 점프 H_max 10.11m·D_max 11.56m·§15-2)", EditorStyles.miniBoldLabel);
|
|
// [5-9]
|
|
config.platformDensity = EditorGUILayout.Slider("Platform Density", config.platformDensity, 0f, 1f);
|
|
config.minPlatformGapTiles = EditorGUILayout.IntSlider("Min Platform Gap (Tile)", config.minPlatformGapTiles, 1, 10);
|
|
config.maxPlatformGapTiles = EditorGUILayout.IntSlider("Max Platform Gap (Tile)", config.maxPlatformGapTiles, config.minPlatformGapTiles, 12);
|
|
config.minPlatformWidthTiles = EditorGUILayout.IntSlider("Min Platform Width (Tile)", config.minPlatformWidthTiles, 2, 8);
|
|
config.maxPlatformWidthTiles = EditorGUILayout.IntSlider("Max Platform Width (Tile)", config.maxPlatformWidthTiles, config.minPlatformWidthTiles, 12);
|
|
config.minPlatformHeight = EditorGUILayout.IntSlider("Min Platform Height (Tile)", config.minPlatformHeight, 1, 10);
|
|
config.maxPlatformHeight = EditorGUILayout.IntSlider("Max Platform Height (Tile)", config.maxPlatformHeight, config.minPlatformHeight, 10);
|
|
|
|
EditorGUILayout.LabelField("Start·Goal (§15-6 좌측 고정)", EditorStyles.miniBoldLabel);
|
|
// [10-11]
|
|
config.startMarginTiles = EditorGUILayout.IntSlider("Start Margin (Tile)", config.startMarginTiles, 2, 20);
|
|
config.goalMarginTiles = EditorGUILayout.IntSlider("Goal Margin (Tile)", config.goalMarginTiles, 2, 20);
|
|
|
|
EditorGUILayout.LabelField("Enemy 영역 (§15-8 OVERRIDE MonsterRandomizer)", EditorStyles.miniBoldLabel);
|
|
config.flyingEnemyRatio = EditorGUILayout.Slider("Flying Enemy Ratio", config.flyingEnemyRatio, 0f, 1f);
|
|
|
|
EditorGUILayout.LabelField("Enemy 재-spawn (§15-7 OVERRIDE)", EditorStyles.miniBoldLabel);
|
|
config.respawnTimer = EditorGUILayout.Slider("Respawn Timer (sec)", config.respawnTimer, 0f, 60f);
|
|
config.respawnMaxCount = EditorGUILayout.IntSlider("Respawn Max Count (-1=unlimited)", config.respawnMaxCount, -1, 20);
|
|
|
|
EditorGUILayout.LabelField("Boss Room (§15-9 OVERRIDE)", EditorStyles.miniBoldLabel);
|
|
config.bossRoomEnabled = EditorGUILayout.Toggle("Boss Room Enabled", config.bossRoomEnabled);
|
|
config.bossRoomLengthTiles = EditorGUILayout.IntSlider("Boss Room Length (Tile)", config.bossRoomLengthTiles, 10, 50);
|
|
|
|
// Advanced 영역 (chunk·perlin — §15-3 기본 고정·EditorWindow 미노출이나 고급용 toggle)
|
|
advancedOptionsExpanded = EditorGUILayout.Foldout(advancedOptionsExpanded, "Advanced (chunk·perlin — §15-3 기본 고정)");
|
|
if (advancedOptionsExpanded)
|
|
{
|
|
config.chunkSizeTiles = EditorGUILayout.IntSlider("Chunk Size (Tile)", config.chunkSizeTiles, 5, 50);
|
|
config.introPlatformDensityMultiplier = EditorGUILayout.Slider("Intro Density Mul", config.introPlatformDensityMultiplier, 0f, 2f);
|
|
config.midPlatformDensityMultiplier = EditorGUILayout.Slider("Mid Density Mul", config.midPlatformDensityMultiplier, 0f, 2f);
|
|
config.bossPrePlatformDensityMultiplier = EditorGUILayout.Slider("BossPre Density Mul", config.bossPrePlatformDensityMultiplier, 0f, 2f);
|
|
config.groundBaseY = EditorGUILayout.IntSlider("Ground Base Y", config.groundBaseY, -10, 10);
|
|
config.groundPerlinAmplitude = EditorGUILayout.IntSlider("Ground Perlin Amp", config.groundPerlinAmplitude, 0, 5);
|
|
config.groundPerlinScale = EditorGUILayout.Slider("Ground Perlin Scale", config.groundPerlinScale, 0.01f, 0.5f);
|
|
}
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
{
|
|
EditorUtility.SetDirty(config);
|
|
}
|
|
}
|
|
EditorGUILayout.EndScrollView();
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.HelpBox("MapGenerationConfig 영역 필수. Project 영역 SO 영역 영역 생성 후 Drag.", MessageType.Info);
|
|
}
|
|
|
|
EditorGUILayout.Space(4);
|
|
|
|
// ─────────── 액션 영역 ───────────
|
|
using (new EditorGUI.DisabledScope(config == null))
|
|
{
|
|
EditorGUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("Generate (랜덤)", GUILayout.Height(28), GUILayout.Width(120)))
|
|
{
|
|
currentBlueprint = MapGenerator.Generate(config);
|
|
}
|
|
using (new EditorGUI.DisabledScope(currentBlueprint == null))
|
|
{
|
|
if (GUILayout.Button("Apply to Scene", GUILayout.Height(28), GUILayout.Width(140)))
|
|
{
|
|
MapApplier.Apply(currentBlueprint, config);
|
|
// Scene 영역 변경 — Undo 영역 외 (BT 영역 PD 직접 변경)
|
|
}
|
|
}
|
|
if (GUILayout.Button("Clear Scene", GUILayout.Height(28), GUILayout.Width(120)))
|
|
{
|
|
MapApplier.Clear();
|
|
}
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
zoom = EditorGUILayout.Slider("Zoom", zoom, 0.2f, 3f);
|
|
showJumpReach = EditorGUILayout.ToggleLeft("Show Jump Reach", showJumpReach, GUILayout.Width(160));
|
|
EditorGUILayout.EndHorizontal();
|
|
}
|
|
|
|
EditorGUILayout.Space(4);
|
|
|
|
// ─────────── 미리보기 영역 ───────────
|
|
if (currentBlueprint != null)
|
|
{
|
|
DrawPreviewCanvas();
|
|
DrawBlueprintStats();
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.HelpBox("Generate 영역 영역 미리보기.", MessageType.None);
|
|
}
|
|
}
|
|
|
|
void DrawPreviewCanvas()
|
|
{
|
|
int mh = Mathf.Max(8, currentBlueprint.heightTiles + 8);
|
|
float canvasW = currentBlueprint.lengthTiles * MapPreviewRenderer.TILE_PIXEL * zoom;
|
|
float canvasH = mh * MapPreviewRenderer.TILE_PIXEL * zoom;
|
|
|
|
var viewRect = GUILayoutUtility.GetRect(position.width - 20, position.height - 360);
|
|
previewScroll = GUI.BeginScrollView(viewRect, previewScroll, new Rect(0, 0, canvasW, canvasH));
|
|
|
|
// 배경
|
|
EditorGUI.DrawRect(new Rect(0, 0, canvasW, canvasH), new Color(0.1f, 0.1f, 0.12f));
|
|
|
|
MapPreviewRenderer.Draw(currentBlueprint, zoom, Vector2.zero, showJumpReach);
|
|
|
|
GUI.EndScrollView();
|
|
}
|
|
|
|
void DrawBlueprintStats()
|
|
{
|
|
var bp = currentBlueprint;
|
|
EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
EditorGUILayout.LabelField(
|
|
$"seed={bp.generationSeed} length={bp.lengthTiles}T height={bp.heightTiles}T " +
|
|
$"terrain={bp.terrain.Count} platforms={bp.platforms.Count} spawnPoints={bp.spawnPoints.Count}",
|
|
EditorStyles.miniLabel);
|
|
EditorGUILayout.EndHorizontal();
|
|
}
|
|
}
|
|
}
|