using System; using System.Collections.Generic; using System.Globalization; using TKS.OutGame; using UnityEngine; using UnityEngine.UI; namespace TKS { /// /// 스킬 테스트 씬(Assets/Scenes/SkillTest.unity · 메뉴 TKS/Skill Test/Build Scene · 2026-11-09 PD /// 「유닛마다 액티브 스킬을 구현하기 쉽도록 목록에서 유닛을 선택 · 선택된 유닛으로 기본 스킬 사용 방식 및 슬링샷 조작이 가능한 공간」). /// WL #947 스킬 테스트 씬과 같은 역할 — 전투 코드(BattleManager · SlingshotInput · ActionResolver · SkillSystem · BattleHUD)는 그대로 쓰고 /// 월드맵·아웃게임·세이브 없이 「고른 영웅 1 + 더미」 만 세운다. /// 더미 = 죽지 않음 · 기본 행동 안 함(토글) · 배치 = 표 Resources/Skills/skill_test.csv(영웅 출발 자리 기준 상대 좌표). /// 왼쪽 위 「유닛」 = 영웅 목록(heroes.csv · 병사 제외) · 「이펙트」 = 팩 이펙트 미리보기(에디터 전용 · Assets/VFX 프리팹 검색 → 고른 영웅에 띄움 · 경로 복사). /// 스킬 이펙트 값 = Resources/Skills/skill_vfx.csv(SkillVfx) · 「다시 배치」 = 표 다시 읽기 + 처음 자리. /// public class SkillTestBootstrap : MonoBehaviour { public const string DummyTablePath = "Skills/skill_test"; const string PrefKey = "TKS_SKILLTEST_HERO"; public const string VfxRoot = "Assets/VFX"; /// 「기운 시험」 스위치가 켜는 이펙트 표 키(skill_vfx.csv test_aura 행). public const string AuraTestKey = "test_aura"; public BalanceConfig Config; public static SkillTestBootstrap Instance { get; private set; } public BattleManager Battle { get; private set; } public BattleHUD Hud { get; private set; } public SlingshotInput Sling { get; private set; } public CameraController CameraCtrl { get; private set; } public HeroDb.Hero Current { get; private set; } public IReadOnlyList Heroes { get { return heroes; } } public bool NoCooldown = true; public bool EnemyActs; /// 「더미 행동 끔」일 때 적 턴이 머무는 시간(초) — 지속 효과(고육계 실드 등)·상태 이상(출혈·혼란)이 다음 내 턴까지 남는 것을 눈으로 확인(2026-11-13 PD). public float EnemyHoldSeconds = 2f; public bool HeroInvincible = true; // 적 더미 수·병종(PD 2026-11-10 「테스트 씬에 등장할 적 유닛을 1~3마리까지 지정」): 표 skill_test.csv 의 적 줄 위에서부터 N 개 · 병종은 버튼으로 바꿈(PlayerPrefs) public const int MaxEnemies = 3; const string EnemyCountKey = "TKS_SKILLTEST_ENEMY_N"; const string EnemyTypeKey = "TKS_SKILLTEST_ENEMY_T"; public int EnemyCount = MaxEnemies; // 아군 더미 · 적 공격(호위 시험 · PD 2026-11-12 「호위 = 적이 공격할 때 플레이어가 조작하지 않아도 호위 대상 유닛 위치로 이동한 뒤 대신 피해를 받는 효과 · // 의도대로 동작하는지 테스트 씬에서 적이 공격하게 하는 기능을 추가해 확인」): 자리·이름·병종 = 표 skill_test.csv 의 e_type = ally 줄 const string AllyKey = "TKS_SKILLTEST_ALLY"; const string ToolsFoldKey = "TKS_SKILLTEST_TOOLS_FOLD"; public bool AllyDummy; bool allyInTable; Vector2 allyOffset; string allyName = ""; UnitType allyType = UnitType.Infantry; float allyHp = 1f; bool enemyAttacking; int restartCount; readonly int[] enemyTypeOverride = { -1, -1, -1 }; readonly UnitType[] enemyTypeDefault = { UnitType.Infantry, UnitType.Spear, UnitType.Cavalry }; static readonly UnitType[] TypeCycle = { UnitType.Infantry, UnitType.Spear, UnitType.Cavalry, UnitType.Archer, UnitType.Strategist }; // 연출 완료 체크(PD 2026-11-10 「연출이 완료된 유닛은 체크박스로 체크 · 그 영웅은 목록 최하단으로」): 표 = Assets/Data/SkillTest/skill_vfx_done.csv(조직 공유 · git) public const string DoneTablePath = "Data/SkillTest/skill_vfx_done.csv"; readonly HashSet done = new HashSet(); readonly List baseOrder = new List(); readonly List heroes = new List(); readonly List blockers = new List(); Camera cam; Text infoText; Text cdLabel, enemyLabel, invLabel, auraLabel, enemyCountLabel, doneLabel, allyLabel; readonly Text[] enemyTypeLabels = new Text[MaxEnemies]; RectTransform heroPanel, fxPanel, topPanel; Transform heroContent; void Awake() { Instance = this; if (Config == null) Config = Resources.Load("BalanceConfig"); if (Config == null) { Debug.LogError("[TKS] BalanceConfig 자산이 없습니다. 메뉴 TKS/Setup Project 를 실행하세요."); return; } cam = Camera.main; if (cam == null) { var cgo = new GameObject("Main Camera"); cgo.tag = "MainCamera"; cam = cgo.AddComponent(); } cam.orthographic = true; cam.clearFlags = CameraClearFlags.SolidColor; cam.backgroundColor = new Color(0.07f, 0.09f, 0.11f); cam.transform.position = new Vector3(0f, 0f, -10f); cam.nearClipPlane = 0.1f; cam.farClipPlane = 100f; cam.transparencySortMode = TransparencySortMode.CustomAxis; cam.transparencySortAxis = Vector3.up; cam.depthTextureMode |= DepthTextureMode.Depth; // 이펙트 셰이더 소프트 파티클(GameBootstrap 과 같음) var board = new GameObject("Board").AddComponent(); board.Build(Config.boardSize, Config.boardArt); CameraCtrl = cam.GetComponent(); if (CameraCtrl == null) CameraCtrl = cam.gameObject.AddComponent(); CameraCtrl.Init(board, Config.cameraViewHeight, Config.cameraMinViewHeight, Config.cameraMaxViewHeight); Battle = new GameObject("BattleManager").AddComponent(); Battle.Configure(Config, board); Battle.LineupProvider = Lineup; Battle.EnemyHold = !EnemyActs; Battle.EnemyHoldSeconds = EnemyHoldSeconds; Hud = new GameObject("HUD").AddComponent(); Hud.Build(Battle, cam, CameraCtrl); Battle.Hud = Hud; Sling = new GameObject("SlingshotInput").AddComponent(); Sling.Init(Battle, cam, Hud, CameraCtrl); Sling.BlockPress = OverPanel; Battle.Sling = Sling; if (Sling.Matchup != null) Destroy(Sling.Matchup); // 스킬 테스트 = 이펙트 확인 전용 → 조준 중 상성 표시(적 머리 위 초록·붉은 세모)를 띄우지 않는다(2026-11-13 PD 「녹색 아이콘은 제거」) var cc = CameraCtrl; Battle.UnitActing += u => cc.Follow(u.transform); Battle.PhaseChanged += OnPhase; Battle.StageStarted += () => cc.SnapTo(Focus()); var db = OutGameData.Default; if (db != null && db.Heroes != null) foreach (var h in db.Heroes.heroes) if (h != null && !h.isSoldier && !string.IsNullOrEmpty(h.id)) heroes.Add(h); if (heroes.Count == 0) { Debug.LogError("[TKS] 스킬 테스트: 영웅 표가 비었습니다(메뉴 TKS/Import OutGame Data)."); return; } // 진영(촉 · 위 · 오 · 군) 순으로 묶되 진영 안은 표 순서 그대로(안정 정렬) var order = new List(); foreach (var h in heroes) if (!order.Contains(h.faction)) order.Add(h.faction); var sorted = new List(); foreach (var f in order) foreach (var h in heroes) if (h.faction == f) sorted.Add(h); baseOrder.AddRange(sorted); LoadDone(); SortHeroes(); EnemyCount = Mathf.Clamp(PlayerPrefs.GetInt(EnemyCountKey, MaxEnemies), 1, MaxEnemies); for (int i = 0; i < MaxEnemies; i++) enemyTypeOverride[i] = PlayerPrefs.GetInt(EnemyTypeKey + i, -1); AllyDummy = PlayerPrefs.GetInt(AllyKey, 0) == 1; BuildUi(); string last = PlayerPrefs.GetString(PrefKey, ""); var first = heroes.Find(h => h.id == last) ?? heroes[0]; SelectHero(first); } // ---------- 연출 완료 표 ---------- /// 미완료 = 진영 순(촉·위·오·군 · 표 순서) 위 · 완료 = 맨 아래(같은 순서). void SortHeroes() { heroes.Clear(); foreach (var h in baseOrder) if (!done.Contains(h.id)) heroes.Add(h); foreach (var h in baseOrder) if (done.Contains(h.id)) heroes.Add(h); } static string DonePath { get { return System.IO.Path.Combine(Application.dataPath, DoneTablePath); } } void LoadDone() { done.Clear(); var p = DonePath; if (!System.IO.File.Exists(p)) return; bool head = true; foreach (var raw in System.IO.File.ReadAllLines(p)) { var line = raw.TrimStart(''); if (line.Trim().Length == 0 || line.TrimStart().StartsWith("#")) continue; if (head) { head = false; continue; } var id = SkillVfx.SplitCsv(line)[0].Trim(); if (id.Length > 0) done.Add(id); } } /// 완료 표 저장(에디터 전용 · 영웅 목록 순서 = 기본 순서 · 날짜 = 체크한 날). void SaveDone() { #if UNITY_EDITOR var old = new Dictionary(); var p = DonePath; if (System.IO.File.Exists(p)) foreach (var raw in System.IO.File.ReadAllLines(p)) { var c = SkillVfx.SplitCsv(raw.TrimStart('')); if (c.Length >= 2) old[c[0].Trim()] = c[1].Trim(); } var sb = new System.Text.StringBuilder(); sb.Append("s_hero,s_date,Memo\n"); sb.Append("# 스킬 테스트 씬 「연출 완료」 체크(PD 2026-11-10) — 여기 있는 영웅 = 연출 개선 끝 · 테스트 씬 영웅 목록 맨 아래 · 연출 개선 요청은 목록 첫 번째(미완료) 영웅부터\n"); string today = DateTime.Now.ToString("yyyy-MM-dd"); foreach (var h in baseOrder) { if (!done.Contains(h.id)) continue; string d; sb.Append(h.id).Append(',').Append(old.TryGetValue(h.id, out d) && d.Length > 0 && d != "s_date" ? d : today).Append(',').Append(h.nameKo).Append('\n'); } System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(p)); System.IO.File.WriteAllText(p, sb.ToString(), new System.Text.UTF8Encoding(true)); #endif } void ToggleDone(HeroDb.Hero h) { if (h == null) return; if (!done.Remove(h.id)) done.Add(h.id); SaveDone(); SortHeroes(); FillHeroList(); RefreshInfo(); } void OnDestroy() { if (Instance == this) Instance = null; SkillVfx.TestTravelKey = ""; // 시험 키가 다른 씬(실제 전투)으로 새지 않게 } // ---------- 전투 구성 ---------- List Lineup() { var list = new List(); var h = Current; if (h == null) return list; list.Add(new LineupEntry { slot = heroSlot, id = h.id, name = h.nameKo, type = h.type, art = h.art, hpMult = h.hpMult, atkMult = h.atkMult, defMult = h.defMult, skillActive = h.skillActive ?? "", skillPassive = h.skillPassive ?? "", activeLv = 1, passiveLv = 1, passiveMult = 1f, general = true, }); var sp = Config.playerSpawnPoints; if (AllyDummy && allyInTable && sp != null && sp.Length > 1) // 자리 = 영웅 아닌 칸에 세운 뒤 Restart 에서 표 좌표로 옮김 list.Add(new LineupEntry { slot = (heroSlot + 1) % sp.Length, id = "", name = allyName, type = allyType, art = AllyArt(allyType), hpMult = allyHp }); return list; } /// 아군 더미 그림 = 영웅 표의 같은 병종 병사(isSoldier) 그림(없으면 도형). string AllyArt(UnitType t) { var db = OutGameData.Default; if (db != null && db.Heroes != null) foreach (var h in db.Heroes.heroes) if (h != null && h.isSoldier && h.type == t && !string.IsNullOrEmpty(h.art)) return h.art; return ""; } bool IsAllyDummy(Unit u) { return u != null && u.Faction == Faction.Player && string.IsNullOrEmpty(u.HeroId) && u.DisplayName == allyName; } public void SelectHero(HeroDb.Hero h) { if (h == null) return; Current = h; PlayerPrefs.SetString(PrefKey, h.id); if (heroPanel != null) heroPanel.gameObject.SetActive(false); FillHeroList(); // 고른 영웅 줄 강조 Restart(); } /// 처음 자리로 다시 배치(표 skill_vfx.csv · skill_test.csv 다시 읽음). public void Restart() { if (Battle == null || Current == null) return; restartCount++; // 「⚔ 적 공격」 도중 다시 배치 = 그 공격 루틴을 끝냄(공격 처리는 BattleManager 에서 돌아 StartMode 가 함께 멈춤) enemyAttacking = false; Battle.EnemyHold = !EnemyActs; Battle.EnemyHoldSeconds = EnemyHoldSeconds; if (CameraCtrl != null) CameraCtrl.SetViewHeight(Config.cameraViewHeight); // 영웅 고를 때·다시 배치 = 기본 확대(PD 2026-11-10 「유비를 선택할 때 화면이 줌인된 상태가 되지 않도록」) var stage = MakeStage(); // 영웅 자리(heroSlot)도 이 표에서 → Lineup 보다 먼저 var mode = new BattleMode { kind = "skilltest", stage = stage, maxTurns = 0, onExit = Restart }; Battle.StartMode(mode); foreach (var u in Battle.Units) if (IsAllyDummy(u)) u.Position = HeroSpawn + allyOffset; ApplyFlags(); RefreshInfo(); } /// 영웅 출발 자리 = BalanceConfig.playerSpawnPoints[heroSlot](표 skill_test.csv 의 e_type = hero 행 n_slot). int heroSlot; Vector2 HeroSpawn { get { var sp = Config.playerSpawnPoints; return sp != null && sp.Length > 0 ? sp[Mathf.Clamp(heroSlot, 0, sp.Length - 1)] : Vector2.zero; } } BalanceConfig.StageDef MakeStage() { var st = new BalanceConfig.StageDef { title = "스킬 테스트", subtitle = "", aiAccuracy = 1f, aiAggroRange = 999f }; var ta = Resources.Load(DummyTablePath); heroSlot = 0; if (ta == null) return st; var rows = new List(); string[] head = null; foreach (var raw in ta.text.Replace("\r", "").Split('\n')) { var line = raw.TrimStart(''); if (line.Trim().Length == 0 || line.TrimStart().StartsWith("#")) continue; var c = SkillVfx.SplitCsv(line); if (head == null) head = c; else rows.Add(c); } if (head == null) return st; int iType = Array.IndexOf(head, "e_type"), iSlot = Array.IndexOf(head, "n_slot"); allyInTable = false; foreach (var c in rows) // 영웅 자리 먼저(더미 좌표 = 영웅 자리 기준) · 아군 더미 줄(e_type = ally) { string et = iType >= 0 && iType < c.Length ? c[iType].Trim().ToLowerInvariant() : ""; if (et == "ally" && !allyInTable) { allyInTable = true; allyOffset = new Vector2(F(Col(head, c, "f_dx")), F(Col(head, c, "f_dy"))); float hp = F(Col(head, c, "f_hp")); allyHp = hp > 0f ? hp : 1f; string n = Col(head, c, "s_name"); allyName = n.Length > 0 ? n : "아군 더미"; UnitType at; allyType = Enum.TryParse(Col(head, c, "e_unit"), true, out at) ? at : UnitType.Infantry; } if (et != "hero") continue; if (iSlot >= 0 && iSlot < c.Length) int.TryParse(c[iSlot].Trim(), out heroSlot); } head = null; int slot = 0; // 적 줄 순번(위에서부터 = 적 1·2·3) foreach (var raw in ta.text.Replace("\r", "").Split('\n')) { var line = raw.TrimStart(''); if (line.Trim().Length == 0 || line.TrimStart().StartsWith("#")) continue; var c = SkillVfx.SplitCsv(line); if (head == null) { head = c; continue; } UnitType type = UnitType.Infantry; float dx = 0f, dy = 0f, hp = 1f; string name = ""; bool skip = false; for (int i = 0; i < head.Length && i < c.Length; i++) { string k = head[i].Trim(), v = c[i].Trim(); if (v.Length == 0) continue; if (k == "e_type") { if (v.ToLowerInvariant() == "hero" || !Enum.TryParse(v, true, out type)) skip = true; } else if (k == "f_dx") dx = F(v); else if (k == "f_dy") dy = F(v); else if (k == "f_hp") hp = F(v); else if (k == "s_name") name = v; } if (skip) continue; if (slot >= MaxEnemies) break; enemyTypeDefault[slot] = type; int ov = enemyTypeOverride[slot]; if (ov >= 0 && Enum.IsDefined(typeof(UnitType), ov)) type = (UnitType)ov; // 테스트 씬 병종 버튼 slot++; if (slot > EnemyCount) continue; // 적 수 버튼(1~3) — 기본 병종은 끝까지 읽어 둠 st.enemies.Add(new BalanceConfig.EnemySpawn { name = name.Length > 0 ? name : "더미 " + UnitTypeInfo.Korean(type), type = type, position = HeroSpawn + new Vector2(dx, dy), hpMult = hp > 0f ? hp : 1f, art = DummyArt(type), }); } return st; } static string Col(string[] head, string[] c, string key) { int i = Array.IndexOf(head, key); return i >= 0 && i < c.Length ? c[i].Trim() : ""; } static float F(string v) { float f; return float.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out f) ? f : 0f; } /// 더미 그림 = 스테이지 표의 첫 번째 같은 병종 병사 그림(장수 제외 · 없으면 도형). string DummyArt(UnitType t) { if (Config.stages == null) return ""; foreach (var s in Config.stages) { if (s == null || s.enemies == null) continue; foreach (var e in s.enemies) if (e != null && e.type == t && !e.isBoss && !e.isGeneral && !string.IsNullOrEmpty(e.art)) return e.art; } return ""; } void ApplyFlags() { if (Battle == null) return; foreach (var u in Battle.Units) { if (u == null) continue; u.Invincible = u.Faction == Faction.Enemy || HeroInvincible; } } void OnPhase(BattlePhase p) { if (p != BattlePhase.PlayerTurn) return; ApplyFlags(); foreach (var u in Battle.Units) { if (u == null || !u.IsAlive) continue; if ((u.Faction == Faction.Enemy || IsAllyDummy(u)) && u.Hp < u.MaxHp) { u.Hp = u.MaxHp; // 더미 체력 회복(다음 시험을 같은 조건으로) if (u.View != null) u.View.Refresh(); } if (NoCooldown && u.Faction == Faction.Player && Battle.Skills != null) { var s = Battle.Skills.Of(u); if (s != null) s.ReadyTurn = Battle.TurnNumber; if (u.View != null) u.View.Refresh(); } } if (CameraCtrl != null) CameraCtrl.FocusOn(Focus()); Battle.NotifyChanged(); } Vector2 Focus() { var ps = Battle.AliveUnits(Faction.Player); Vector2 p = ps.Count > 0 ? ps[0].Position : HeroSpawn; return p + new Vector2(0f, Config.cameraViewHeight * 0.2f); } // ---------- UI ---------- static readonly Color PanelColor = new Color(0.08f, 0.09f, 0.12f, 0.92f); static readonly Color BtnColor = new Color(0.22f, 0.26f, 0.34f, 0.95f); static readonly Color BtnOnColor = new Color(0.25f, 0.5f, 0.32f, 0.95f); static readonly Color TextColor = new Color(0.95f, 0.93f, 0.86f); bool OverPanel(Vector2 screen) { foreach (var rt in blockers) if (rt != null && rt.gameObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(rt, screen, null)) return true; return false; } void BuildUi() { var cgo = new GameObject("SkillTestUI"); var canvas = cgo.AddComponent(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = 200; var scaler = cgo.AddComponent(); scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; scaler.referenceResolution = new Vector2(1080f, 1920f); scaler.matchWidthOrHeight = 0.5f; cgo.AddComponent(); var root = cgo.transform; // 왼쪽 위: 유닛 · 이펙트 열기 + 고른 영웅 정보 // 정보 = 영웅 · 액티브 · 패시브(이름 · 발동 · 쿨 · 설명 · 효과 키) · 이펙트 표 행 수(PD 2026-11-10 「선택된 유닛의 액티브·패시브 스킬 정보 출력」) · 높이 = 글 길이에 맞춤 var top = Panel("Top", root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(16f, -290f), new Vector2(InfoWidth, 300f), PanelColor); topPanel = top; blockers.Add(top); Btn(top, "▤ 유닛 선택", new Vector2(10f, -10f), new Vector2(300f, 76f), () => Toggle(heroPanel)); Btn(top, "✦ 이펙트 보기", new Vector2(320f, -10f), new Vector2(310f, 76f), () => Toggle(fxPanel)); doneLabel = Btn(top, "", new Vector2(640f, -10f), new Vector2(InfoWidth - 650f, 76f), () => ToggleDone(Current)); infoText = Label(top, "", 25, TextAnchor.UpperLeft); infoText.supportRichText = true; SetRect(infoText.rectTransform, Vector2.zero, Vector2.one, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); infoText.rectTransform.offsetMin = new Vector2(14f, 6f); infoText.rectTransform.offsetMax = new Vector2(-14f, -94f); // 왼쪽 아래: 시험 토글 + 적 수·병종(4째 줄) var tools = Panel("Tools", root, Vector2.zero, Vector2.zero, Vector2.zero, new Vector2(16f, 40f), new Vector2(560f, 512f), PanelColor); blockers.Add(tools); Btn(tools, "다시 배치", new Vector2(10f, -10f), new Vector2(265f, 74f), Restart); cdLabel = Btn(tools, "", new Vector2(285f, -10f), new Vector2(265f, 74f), () => { NoCooldown = !NoCooldown; OnPhase(Battle.Phase); RefreshInfo(); }); enemyLabel = Btn(tools, "", new Vector2(10f, -94f), new Vector2(265f, 74f), () => { EnemyActs = !EnemyActs; Battle.EnemyHold = !EnemyActs; Battle.EnemyHoldSeconds = EnemyHoldSeconds; RefreshInfo(); }); invLabel = Btn(tools, "", new Vector2(285f, -94f), new Vector2(265f, 74f), () => { HeroInvincible = !HeroInvincible; ApplyFlags(); RefreshInfo(); }); Btn(tools, "이펙트 표 다시 읽기", new Vector2(10f, -178f), new Vector2(265f, 70f), () => { SkillVfx.Reload(); HitFeel.Reload(); Battle.LastMessage = "skill_vfx.csv 다시 읽음 · 행 " + SkillVfx.Rows.Count; Battle.NotifyChanged(); RefreshInfo(); }); // 몸 뒤덮는 기운 시험(PD 2026-11-10 「첨부 같은 느낌으로 몸을 뒤덮는 연출 · 스킬용 시험」): 켜면 슬링샷 공격 돌진에 표 test_aura 행을 함께 띄움 auraLabel = Btn(tools, "", new Vector2(285f, -178f), new Vector2(265f, 70f), () => { SkillVfx.TestTravelKey = SkillVfx.TestTravelKey.Length > 0 ? "" : AuraTestKey; RefreshInfo(); }); // 적 수(1→2→3) · 적 1~3 병종(보병→창병→기병→궁병→책사 · 표 기본으로 돌아오면 덮어쓰기 해제) — 바꾸면 바로 다시 배치 enemyCountLabel = Btn(tools, "", new Vector2(10f, -258f), new Vector2(125f, 74f), () => { EnemyCount = EnemyCount >= MaxEnemies ? 1 : EnemyCount + 1; PlayerPrefs.SetInt(EnemyCountKey, EnemyCount); Restart(); }); for (int i = 0; i < MaxEnemies; i++) { int k = i; enemyTypeLabels[i] = Btn(tools, "", new Vector2(143f + i * 137f, -258f), new Vector2(129f, 74f), () => CycleEnemyType(k)); } // 강제 사망(PD 2026-11-10 「적에게 죽는 상황을 연출하기 위해 강제로 플레이어 죽음 버튼」): 영웅 무적을 무시하고 가장 가까운 적의 공격으로 쓰러짐 → 사망 연출 → 패배 판정 Btn(tools, "☠ 죽음", new Vector2(10f, -342f), new Vector2(265f, 74f), () => StartCoroutine(ForceDeath())); // 호위 시험(PD 2026-11-12): 아군 더미(표 skill_test.csv 의 ally 줄) 켜고 끄기 = 바로 다시 배치 · 적 공격 = 가장 가까운 적이 아군 더미(없으면 영웅)를 1번 공격 Btn(tools, "⚔ 적 공격", new Vector2(285f, -342f), new Vector2(265f, 74f), () => StartCoroutine(EnemyAttack())); allyLabel = Btn(tools, "", new Vector2(10f, -426f), new Vector2(265f, 74f), () => { AllyDummy = !AllyDummy; PlayerPrefs.SetInt(AllyKey, AllyDummy ? 1 : 0); Restart(); }); // 시험 메뉴 접기(PD 2026-11-13 「옵션 메뉴가 화면을 가려서 테스트가 너무 불편 · 버튼을 눌러 최소화 · 토글 버튼을 누르면 다시 활성화」): // 메뉴 바로 위 작은 버튼 = 메뉴 숨기기/보이기 · 접으면 버튼이 왼쪽 아래 구석으로 · 상태는 다음 실행에도(PlayerPrefs) var fold = Panel("ToolsFold", root, Vector2.zero, Vector2.zero, Vector2.zero, new Vector2(16f, 560f), new Vector2(210f, 70f), PanelColor); blockers.Add(fold); Text foldLabel = null; Action applyFold = () => { bool show = PlayerPrefs.GetInt(ToolsFoldKey, 0) == 0; tools.gameObject.SetActive(show); fold.anchoredPosition = new Vector2(16f, show ? 560f : 40f); if (foldLabel != null) foldLabel.text = show ? "▼ 메뉴 접기" : "▲ 메뉴 펴기"; }; foldLabel = Btn(fold, "", new Vector2(5f, -5f), new Vector2(200f, 60f), () => { PlayerPrefs.SetInt(ToolsFoldKey, PlayerPrefs.GetInt(ToolsFoldKey, 0) == 0 ? 1 : 0); applyFold(); }); applyFold(); heroPanel = BuildHeroList(root); blockers.Add(heroPanel); fxPanel = BuildFxBrowser(root); blockers.Add(fxPanel); heroPanel.gameObject.SetActive(false); fxPanel.gameObject.SetActive(false); } void Toggle(RectTransform p) { if (p == null) return; bool on = !p.gameObject.activeSelf; heroPanel.gameObject.SetActive(false); fxPanel.gameObject.SetActive(false); p.gameObject.SetActive(on); } const float InfoWidth = 820f; /// 강제 사망: 영웅(아군 첫 유닛)을 가장 가까운 적의 공격 피해로 쓰러뜨림(무적·부활 등은 무시하고 강제) → 사망 연출이 보이게 1.5초 뒤 패배 판정. System.Collections.IEnumerator ForceDeath() { var ps = Battle.AliveUnits(Faction.Player); if (ps.Count == 0) yield break; var u = ps[0]; Unit by = null; float best = float.MaxValue; foreach (var e in Battle.AliveUnits(Faction.Enemy)) { float d = Vector2.Distance(e.Position, u.Position); if (d < best) { best = d; by = e; } } u.Invincible = false; if (Battle.Skills != null) Battle.Skills.Hit(u, u.MaxHp * 10, by, HitKind.Attack); if (u.IsAlive) u.TakeDamage(u.Hp); // 무적·부활 스킬도 무시 Battle.LastMessage = u.DisplayName + " 강제 사망(테스트)"; Battle.NotifyChanged(); yield return new WaitForSeconds(1.5f); if (Battle != null) Battle.CheckBattleEnd(); } /// /// 적 공격(호위 시험): 아군 더미(없으면 영웅)에 가장 가까운 적이 실제 적 조준(EnemyAI.Decide · 정확도 1 · 교전 범위 무시)으로 1번 공격 → /// 끝나면 아군 차례로 돌아옴 · 아래 한 줄 = 영웅이 받은 피해 · 영웅이 움직인 거리 · 대상이 받은 피해. /// System.Collections.IEnumerator EnemyAttack() { if (Battle == null || enemyAttacking || Battle.Phase != BattlePhase.PlayerTurn) yield break; Unit target = null, hero = null; foreach (var u in Battle.AliveUnits(Faction.Player)) { if (IsAllyDummy(u)) target = u; else if (hero == null) hero = u; } if (target == null) target = hero; if (target == null) yield break; Unit e = null; float best = float.MaxValue; foreach (var x in Battle.AliveUnits(Faction.Enemy)) { float d = Vector2.Distance(x.Position, target.Position); if (d < best) { best = d; e = x; } } if (e == null) yield break; var aim = EnemyAI.Decide(e, new List { target }, 1f, float.MaxValue, Battle.Rng, Battle.Board, Config); if (!aim.HasValue) { Battle.LastMessage = e.DisplayName + " 조준 실패(테스트)"; Battle.NotifyChanged(); yield break; } enemyAttacking = true; Vector2 heroAt = hero != null ? hero.Position : Vector2.zero; int heroHp = hero != null ? hero.Hp : 0, targetHp = target.Hp; Battle.ForcePhase(BattlePhase.EnemyTurn); // 공격하는 동안 슬링샷 입력을 막음 e.ResetForNewTurn(); if (CameraCtrl != null) CameraCtrl.Follow(e.transform); bool done = false; float far = 0f; int epoch = restartCount; Battle.StartCoroutine(Then(Battle.ResolveForTest(e, aim.Value, false, new ActionOutcome()), () => done = true)); while (!done) { if (restartCount != epoch) yield break; if (hero != null) far = Mathf.Max(far, Vector2.Distance(heroAt, hero.Position)); yield return null; } enemyAttacking = false; string msg = e.DisplayName + " → " + target.DisplayName + " 공격(테스트)"; if (hero != null && hero != target) msg += string.Format(" · {0} 피해 {1} · 달려간 거리 {2:0.00} · 복귀 뒤 차 {3:0.00} · {4} 피해 {5}", hero.DisplayName, heroHp - hero.Hp, far, Vector2.Distance(heroAt, hero.Position), target.DisplayName, targetHp - target.Hp); Battle.ForcePhase(BattlePhase.PlayerTurn); Battle.LastMessage = msg; Battle.NotifyChanged(); Debug.Log("[TKS] " + msg); } static System.Collections.IEnumerator Then(System.Collections.IEnumerator a, System.Action done) { yield return a; done(); } void CycleEnemyType(int slot) { int cur = enemyTypeOverride[slot] >= 0 ? enemyTypeOverride[slot] : (int)enemyTypeDefault[slot]; int idx = Array.IndexOf(TypeCycle, (UnitType)cur); var next = TypeCycle[(idx + 1) % TypeCycle.Length]; enemyTypeOverride[slot] = next == enemyTypeDefault[slot] ? -1 : (int)next; PlayerPrefs.SetInt(EnemyTypeKey + slot, enemyTypeOverride[slot]); if (slot >= EnemyCount) { EnemyCount = slot + 1; // 꺼진 칸의 병종을 바꾸면 그 칸까지 켬 PlayerPrefs.SetInt(EnemyCountKey, EnemyCount); } Restart(); } UnitType EnemyType(int slot) { return enemyTypeOverride[slot] >= 0 ? (UnitType)enemyTypeOverride[slot] : enemyTypeDefault[slot]; } RectTransform BuildHeroList(Transform root) { var p = Panel("HeroList", root, new Vector2(0f, 0f), new Vector2(0.78f, 1f), new Vector2(0f, 1f), new Vector2(16f, -550f), Vector2.zero, PanelColor); p.offsetMin = new Vector2(16f, 484f); p.offsetMax = new Vector2(0f, -550f); heroContent = Scroll(p); FillHeroList(); return p; } /// 영웅 목록: 미완료(진영별 머리글) → 「연출 완료」 머리글 → 완료 영웅 · 각 줄 오른쪽 = 완료 체크(●완료 / ○). void FillHeroList() { if (heroContent == null) return; for (int i = heroContent.childCount - 1; i >= 0; i--) Destroy(heroContent.GetChild(i).gameObject); string lastFaction = null; bool doneHeader = false; foreach (var h in heroes) { bool isDone = done.Contains(h.id); if (isDone && !doneHeader) { doneHeader = true; Header("— 연출 완료 (" + done.Count + ") —", new Color(0.55f, 0.9f, 0.6f)); } else if (!isDone && h.faction != lastFaction) { lastFaction = h.faction; Header("— " + UiKit.FactionKo(h.faction) + " —", new Color(1f, 0.85f, 0.4f)); } var hero = h; var a = SkillCatalog.Get(h.skillActive); string text = h.nameKo + " · " + UnitTypeInfo.Korean(h.type) + " · " + UiKit.FactionKo(h.faction) + (a != null ? " · " + a.NameKo + "(" + TriggerKo(a.Trigger) + ")" : " · 액티브 없음"); var b = ListItem(heroContent, text, () => SelectHero(hero)); b.gameObject.name = "Hero_" + h.id; b.GetComponentInChildren().rectTransform.offsetMax = new Vector2(-170f, 0f); // 오른쪽 완료 버튼 자리 if (Current != null && Current.id == h.id) b.GetComponent().color = BtnOnColor; // 완료 체크(목록 버튼 위 오른쪽 작은 버튼 · 누름 = 이 버튼만) var cb = Panel("Done", b.transform, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-6f, 0f), new Vector2(150f, 64f), isDone ? new Color(0.2f, 0.55f, 0.3f, 1f) : new Color(0.12f, 0.14f, 0.18f, 1f)); cb.gameObject.AddComponent