using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; namespace TKS.OutGame { /// /// 아웃게임 2차 화면 검증 캡처(PD #1093 C · 에디터 DataImporter.CaptureC 가 SessionState 로 출력 폴더를 넘기면 생성 · 세이브 = 메모리 전용 신규 유저). /// 캡처용 재화·진행을 넣은 뒤 훈련 · 순찰 · 개발 · 보물 보유/세트/상자 · 탑 · 던전 · 투기장 · 도감 10장 + log · 끝나면 스스로 종료. /// public class OutGameCaptureDriverC : MonoBehaviour { public const string DirKey = "TKS_OUTGAME_C_CAPTURE_DIR"; public string OutputDir; public int Width = 720; public int Height = 1280; readonly List log = new List(); int shot = 1; #if UNITY_EDITOR [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] static void AutoSpawn() { string dir = UnityEditor.SessionState.GetString(DirKey, ""); if (string.IsNullOrEmpty(dir)) return; UnityEditor.SessionState.EraseString(DirKey); var d = new GameObject("OutGameCaptureDriverC").AddComponent(); d.OutputDir = dir; } #endif IEnumerator Start() { Directory.CreateDirectory(OutputDir); yield return null; yield return null; var root = OutGameRoot.Instance; var cam = Camera.main; if (root == null || cam == null) { Log("FAIL: OutGameRoot 또는 카메라 없음"); Finish(1); yield break; } var s = root.Session; var db = s.Db; var d = s.Save; Log("memoryOnly=" + SaveStore.MemoryOnly + " newUser=" + s.IsNewUser + " heroes(db)=" + db.Heroes.heroes.Count + " treasures(db)=" + db.Treasures.items.Count); // 캡처용 진행(메모리 세이브만): 재화 · 훈련(보병 HP·공 Max · 방 9) · 순찰 7시간 · 개발 일부 · 상자 열기로 보물 · 상자 보유 · 포인트 d.gold = 120000; d.gem = 3000; d.inv.blueprint = 30; d.inv.iron = 300; var inf = UnitType.Infantry; for (int i = 0; i < db.Training.MaxLevel; i++) { TrainingRules.Level(db, d, inf, 0); TrainingRules.Level(db, d, inf, 1); if (i < db.Training.MaxLevel - 1) TrainingRules.Level(db, d, inf, 2); } d.patrol.startAt = SaveStore.Iso(s.Now.AddHours(-7)); var first = db.Dev.InBranch(db.Dev.Branches[0]); for (int i = 0; i < first[0].lvMax; i++) DevRules.Upgrade(db, d, first[0].id); for (int i = 0; i < 4 && first.Count > 1; i++) DevRules.Upgrade(db, d, first[1].id); var rng = new System.Random(1093); Counts.Set(d.inv.chests, "gold", 6); Counts.Set(d.inv.chests, "silver", 10); for (int i = 0; i < 6; i++) TreasureRules.Open(db, d, "gold", rng); for (int i = 0; i < 10; i++) TreasureRules.Open(db, d, "silver", rng); foreach (var t in d.inv.treasures) if (t.star == 0 && rng.NextDouble() < 0.6) t.star = 1 + rng.Next(3); Counts.Set(d.inv.chests, "bronze", 4); Counts.Set(d.inv.chests, "silver", 18); Counts.Set(d.inv.chests, "gold", 3); Counts.Set(d.inv.chests, "general", 1); d.inv.chestPoints = 35; TreasureRules.AddCount(d, BattleEvents.Battles, 45); s.Commit(); Log("seed: gold=" + d.gold + " treasures=" + d.inv.treasures.Count + " infantry rank=" + TrainingRules.Rank(d, inf) + " dev=" + DevRules.TotalLevels(d)); root.Show(root.Domestic); root.Domestic.SetTrainType(inf); root.Domestic.SetPage(0); yield return Shot(cam, "domestic_training"); root.Domestic.SetPage(1); var y = PatrolRules.Preview(db, d, PatrolRules.Hours(db, d, s.Now), 1f); Log("patrol hours=" + PatrolRules.Hours(db, d, s.Now).ToString("0.00") + " gold=" + y.gold + " exp=" + y.exp + " gear=" + y.gear + " chests=" + y.chests); yield return Shot(cam, "domestic_patrol"); root.Domestic.SetPage(2); root.Domestic.SetBranch(0); Log("dev nodes(branch 0)=" + root.Domestic.NodeCount + " gold_gain=" + DevRules.Mod(db, d, DevRules.GoldGain)); yield return Shot(cam, "domestic_dev"); root.Show(root.Treasures); root.Treasures.SetPage(0); Log("treasure grid=" + root.Treasures.GridCount + " owned=" + d.inv.treasures.Count + " atk%=" + TreasureRules.StatPct(db, d, "atk").ToString("0.##")); yield return Shot(cam, "treasure_owned"); root.Treasures.SetPage(1); yield return Shot(cam, "treasure_sets"); root.Treasures.SetPage(2); root.Treasures.SelectChest("gem"); yield return Shot(cam, "treasure_chests"); root.Arena.SetPage(0); root.Show(root.Arena); yield return Wait(); root.Arena.SetPage(1); Log("tower next=" + ArenaRules.TowerNext(db, d) + " tickets=" + d.arena.towerTickets); yield return Shot(cam, "arena_tower"); root.Arena.SetPage(2); yield return Shot(cam, "arena_dungeons"); root.Arena.SetPage(3); Log("arena samples=" + d.arena.samples.Count + " rank=" + ArenaRules.Rank(d)); yield return Shot(cam, "arena_pvp"); root.Show(root.HeroList); HeroDetailScreen.ShowCodex(root); Log("codex heroes=" + db.Heroes.heroes.Count); yield return Shot(cam, "hero_codex"); Finish(0); } static IEnumerator Wait() { yield return null; yield return new WaitForSecondsRealtime(0.3f); } IEnumerator Shot(Camera cam, string name) { yield return Wait(); string file = Path.Combine(OutputDir, shot.ToString("00") + "_" + name + ".png"); shot++; yield return CaptureUtil.Capture(cam, Width, Height, file); Log("shot " + file); } void Log(string s) { log.Add(s); Debug.Log("[OutGameCaptureC] " + s); try { File.WriteAllLines(Path.Combine(OutputDir, "capture_log.txt"), log.ToArray()); } catch { } } void Finish(int code) { Log("finish code=" + code); #if UNITY_EDITOR UnityEditor.EditorApplication.Exit(code); #else Application.Quit(code); #endif } } }