ThreeKingdomsSlingshot/Assets/Scripts/Editor/TestMenu.cs

95 lines
4.6 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace TKS.EditorTools
{
/// <summary>
/// 플레이 테스트 전용 메뉴(PD 2026-11-18 「테스트 전용 전 스테이지 열기 및 기준 스펙 편성」 + 게임성 변경안 조준 전환).
/// 값 = PlayerPrefs(TestOptions) — 이 PC 의 에디터에서만 켜진다 · Play 중에도 바꿀 수 있다(편성은 다음 전투부터).
/// </summary>
public static class TestMenu
{
const string Root = "TKS/테스트/";
[MenuItem(Root + "전 스테이지 열기 (군량 면제)", false, 1)]
static void UnlockAll() { TestOptions.UnlockAllStages = !TestOptions.UnlockAllStages; Log(); }
[MenuItem(Root + "전 스테이지 열기 (군량 면제)", true)]
static bool UnlockAllCheck() { Menu.SetChecked(Root + "전 스테이지 열기 (군량 면제)", TestOptions.UnlockAllStages); return true; }
[MenuItem(Root + "기준 스펙 (성장 무시 · 스킬 Lv1)", false, 2)]
static void Spec() { TestOptions.StandardSpec = !TestOptions.StandardSpec; Log(); }
[MenuItem(Root + "기준 스펙 (성장 무시 · 스킬 Lv1)", true)]
static bool SpecCheck() { Menu.SetChecked(Root + "기준 스펙 (성장 무시 · 스킬 Lv1)", TestOptions.StandardSpec); return true; }
[MenuItem(Root + "기준 편성 — 무작위 영웅 5명 (병종당 최대 2)", false, 20)]
static void RandomLineup()
{
var pool = new List<KeyValuePair<string, string>>(); // id, 병종 키
var errors = new List<string>();
var path = Path.Combine(Application.dataPath, "Data/OutGame/heroes.csv");
foreach (var r in StageTable.ReadCsv(File.ReadAllText(path, Encoding.UTF8), "heroes.csv", errors))
{
string soldier;
if (r.TryGetValue("is_soldier", out soldier) && (soldier == "1" || soldier.ToLowerInvariant() == "true")) continue;
pool.Add(new KeyValuePair<string, string>(r["id"], r["unit_type"]));
}
var rng = new System.Random();
var count = new Dictionary<string, int>();
var ids = new List<string>();
while (ids.Count < 5 && pool.Count > 0)
{
var p = pool[rng.Next(pool.Count)];
pool.Remove(p);
int n;
count.TryGetValue(p.Value, out n);
if (n >= 2) continue;
count[p.Value] = n + 1;
ids.Add(p.Key);
}
TestOptions.LineupIds = string.Join(";", ids.ToArray());
Log();
}
[MenuItem(Root + "기준 편성 — 내 편성 쓰기 (비우기)", false, 21)]
static void ClearLineup() { TestOptions.LineupIds = ""; Log(); }
[MenuItem(Root + "조준 — 끌기 거리 + 붉은 구간 치명타 (새)", false, 40)]
static void AimDrag() { TestOptions.AimModeOverride = 1; Log(); }
[MenuItem(Root + "조준 — 끌기 거리 + 붉은 구간 치명타 (새)", true)]
static bool AimDragCheck() { Menu.SetChecked(Root + "조준 — 끌기 거리 + 붉은 구간 치명타 (새)", AimRules.Mode == 1); return true; }
[MenuItem(Root + "조준 — 게이지 거리 (기존 · 보류)", false, 41)]
static void AimGauge() { TestOptions.AimModeOverride = 0; Log(); }
[MenuItem(Root + "조준 — 게이지 거리 (기존 · 보류)", true)]
static bool AimGaugeCheck() { Menu.SetChecked(Root + "조준 — 게이지 거리 (기존 · 보류)", AimRules.Mode == 0); return true; }
[MenuItem(Root + "조준 — 표 값 따름 (ib_ui.csv aim_mode)", false, 42)]
static void AimTable() { TestOptions.AimModeOverride = -1; Log(); }
[MenuItem(Root + "모두 끄기", false, 60)]
static void AllOff()
{
TestOptions.UnlockAllStages = false;
TestOptions.StandardSpec = false;
TestOptions.LineupIds = "";
TestOptions.AimModeOverride = -1;
Log();
}
static void Log()
{
AimRules.Refresh();
Debug.Log("[TKS 테스트] 전 스테이지 열기 " + (TestOptions.UnlockAllStages ? "켬" : "끔") + " · 기준 스펙 " + (TestOptions.StandardSpec ? "켬" : "끔") +
" · 기준 편성 " + (TestOptions.LineupIds.Length > 0 ? TestOptions.LineupIds : "내 편성") + " · 조준 " + (AimRules.Mode == 1 ? "끌기 + 붉은 구간" : "게이지 거리") +
(TestOptions.AimModeOverride < 0 ? "(표 값)" : "(메뉴 덮어쓰기)"));
}
}
}