using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace TKS.OutGame { /// /// 연의 전기 화면(컨텐츠 모드 기획 10판 ② · 2026-11-18) — 표 Resources/UI/Scenario 가 있으면 확정 아트 화면(ArenaScenario · PD 2026-11-18 「연의 전기 통과」 · 서재 · 탭 5 · 두루마리 · 펼침 연출 · 세로 두루마리 상세) · /// 표·그림이 없으면 예전 **더미 UI**(편 목록(편 · 해금 · 연의/열전 진행 ●○) → 편을 누르면 전투 정보 팝업(승리 조건 · 도전 조건 2 · 고정 편성 · 기믹) → 연의 · 열전 입장). /// public partial class ArenaScreen { public const int ScenarioPage = 5; ArenaScenario scenario; // 확정 아트 화면(표 Resources/UI/Scenario · 없으면 null = 더미 UI) RectTransform scenarioSlot; /// 연의 전기 아트 화면(없으면 null · 테스트). public ArenaScenario Scenario { get { return scenario; } } /// 지금 연의 전기 아트 화면이 보이는가(테스트). public bool ScenarioVisible { get { return scenario != null && scenario.Built && scenarioSlot != null && scenarioSlot.gameObject.activeInHierarchy; } } /// Build 에서 제목 띠보다 먼저(화면 전체 · 제목 띠 · 본문 뒤) — 표만 읽음(그림은 처음 열 때). void LoadScenarioView() { scenario = ArenaScenario.Load(this); if (scenario == null) return; scenarioSlot = UiKit.Fill("Scenario", Rt); scenarioSlot.gameObject.SetActive(false); } /// 연의 전기 쪽 = 아트 화면을 켜고 지금 탭을 다시 채움 · 표 없음 · 배경 없음 = false(호출 쪽 = 더미 UI). bool ShowScenarioView() { if (scenario == null || scenarioSlot == null) return false; scenarioSlot.gameObject.SetActive(true); if (scenario.Show(scenarioSlot)) return true; scenarioSlot.gameObject.SetActive(false); // 배경 그림 없음 = 더미 UI(다시 시도하지 않음) scenario = null; return false; } /// 연의 전기 쪽을 떠날 때 · 다시 들어올 때(처음 탭 다시 고름) · 뒤로 = 상세 닫기. void ScenarioPageChanged(int prev, int next) { if (scenario == null) return; if (next != ScenarioPage) scenario.CloseDetail(); else if (prev != ScenarioPage) scenario.ResetTab(); } bool ScenarioBack() { if (page != ScenarioPage || scenario == null || !scenario.DetailOpen) return false; scenario.CloseDetail(); return true; } void ScenarioEntryButton() { UiKit.Btn("Scenario", root, "연의 전기 — 명전 16편", 40, UiKit.Purple, UiKit.White, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -1490f), new Vector2(1032f, 110f), () => SetPage(ScenarioPage)); } void BuildScenario() { ContentTables.Reload(); var d = S.Save; Title("연의 전기"); UiKit.Label(root, "고정 편성 · 고정 능력치(모든 유저 같은 스펙) · 입장 군량 " + ContentTables.Int("scenario", "stamina_cost") + " · 지면 환급", 26, UiKit.InkSoft, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -112f), new Vector2(1032f, 44f), false); var list = ScenarioModeRules.Battles(); float w = 508f, h = 160f; for (int i = 0; i < list.Count; i++) { var b = list[i]; string id = b.S("s_id"); float x = 24f + (i % 2) * (w + 16f), y = 166f + (i / 2) * (h + 10f); bool open = b.I("n_no") > 0 && ScenarioModeRules.Unlocked(d, b); var cell = UiKit.Btn("Ep_" + id, root, "", 26, open ? UiKit.Paper : UiKit.Slot, UiKit.Ink, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, -y), new Vector2(w, h), () => ScenarioInfo(id)); var e = d.scenario.Get(id, false); string stars = e == null ? "○○○ / ○○○" : Dots(e.normal) + " / " + Dots(e.hard); UiKit.Label(cell.transform, b.I("n_no") + ". " + b.S("s_title_ko") + " " + b.I("n_year") + " · " + b.S("s_part") + "", 30, UiKit.Ink, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(14f, -10f), new Vector2(w - 28f, 50f), false); UiKit.Label(cell.transform, (open ? "주역 " + b.S("l_fixed_hero_ko").Replace(";", " · ") : (b.I("n_no") == 0 ? "서장 = 1장 학습 판" : b.S("s_unlock_ko") + " 뒤 열림")) + "\n연의 · 열전 " + stars, 22, UiKit.InkSoft, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(14f, -62f), new Vector2(w - 28f, 90f), false); } } static string Dots(bool[] a) { var s = ""; foreach (var x in a) s += x ? "●" : "○"; return s; } void ScenarioInfo(string id) { var b = ContentTables.Find("scenario_battles", "s_id", id); if (b == null) return; var d = S.Save; string body = "승리 " + b.S("s_win_cond_ko") + "\n도전 1 " + b.S("s_challenge1_ko") + "\n도전 2 " + b.S("s_challenge2_ko") + "\n출전 " + b.S("l_fixed_hero_ko").Replace(";", " · ") + (b.S("l_companion_ko").Length > 0 ? " + " + b.S("l_companion_ko").Replace(";", " · ") : "") + "\n전장 " + b.S("s_gimmick_ko"); var bt = new List(); var wn = ScenarioModeRules.Can(S.Db, d, id, false, S.Now); bt.Add(new OutGameRoot.ModalButton(wn == null ? "연의 출전" : "연의 — " + wn, wn == null ? UiKit.Red : UiKit.Disabled, () => ScenarioGo(id, false))); var wh = ScenarioModeRules.Can(S.Db, d, id, true, S.Now); bt.Add(new OutGameRoot.ModalButton(wh == null ? "열전 출전" : "열전 — " + wh, wh == null ? UiKit.Purple : UiKit.Disabled, () => ScenarioGo(id, true))); bt.Add(new OutGameRoot.ModalButton("닫기", UiKit.Dark, null)); Root.Modal(b.S("s_title_ko"), body, bt.ToArray()); } /// 편 id 출전(연의 · 열전) — 아트 화면 상세의 출전 버튼도 이것. internal void ScenarioGo(string id, bool hard) { var cfg = Root.Battle.Config; var stage = new BalanceConfig.StageDef { title = id, subtitle = "연의 전기", kind = StageKind.Normal, aiAccuracy = 1f, aiAggroRange = 999f }; var b = ContentTables.Find("scenario_battles", "s_id", id); int ch, st; var refSt = b != null && ArenaRules.ParseStageKey(b.S("s_unlock_stage"), out ch, out st) ? ContentEnemyRef.RefStage(cfg, ch) : null; if (refSt != null) { stage.aiAccuracy = refSt.aiAccuracy; stage.aiAggroRange = refSt.aiAggroRange; stage.bgTheme = refSt.bgTheme; } var rules = new ScenarioRules { BattleId = id, Hard = hard, Config = cfg }; var why = rules.Prepare(stage); if (why != null) { Root.Toast(why); return; } var w = S.ScenarioEnter(id, hard); if (w != null) { Root.Toast(w); return; } Root.StartMode(ScenarioModeRules.Kind, id, hard ? 1 : 0, stage, rules.TurnLimitValue, ScenarioPage, rules); } } }