ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Awaken/AwakenWindows.cs

816 lines
48 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 영웅 각성 · 진화 창 9종(2026-11-20 요청서 §0-5 · §5 2차 · 목업 각성진화_img 01~09) — 각성 · 각성 확률 · 높은 등급 경고 · 진화 · 진화 완료 · 비서 교환 · 각성 칸 열림 · 스킬 강화 · 만능 조각 확인.
/// 창 위 = 고른 영웅 카드(초상 · 진영 · 병종 · 승급 등급 · 이름 · ★ · Lv / 최대 · 전투력 · 각성 몫) · ◀ ▶ = 영웅 정보 화면과 같은 순서로 넘김(창을 닫지 않음).
/// 창 = 팝업(OutGameRoot.ModalCustom · Event) · 바뀌면 같은 창을 다시 그린다. 글자 = UI/Awaken/awaken_text · 아이콘·색 = awaken_screen · 값 = 표(C45).
/// </summary>
public static class AwakenWindows
{
public const string Texts = "UI/Awaken/awaken_text";
public const string Table = "UI/Awaken/awaken_screen";
const float W = 940f;
const float L = 34f;
const float RW = 872f;
static Dictionary<string, string> cfg;
static string shopFaction;
static string shopPick;
/// <summary>시험 · 캡처 — 마지막으로 연 창(awaken · prob · warn · evolve · done · shop) · 그 창의 영웅.</summary>
public static string Last { get; private set; }
public static string HeroId { get; private set; }
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetStatics()
{
cfg = null;
shopFaction = shopPick = null;
Last = HeroId = null;
}
static string T(string k)
{
return UiText.T(k).Replace("\\n", "\n");
}
static string F(string k, params string[] a)
{
return UiText.F(k, a).Replace("\\n", "\n");
}
static string N(int v)
{
return v.ToString("N0", CultureInfo.InvariantCulture);
}
static string Cfg(string key, string def = "")
{
if (cfg == null)
{
cfg = new Dictionary<string, string>();
var rows = UiText.Rows(Table);
if (rows != null)
foreach (var r in rows)
{
string k, v;
if (r.TryGetValue("s_key", out k) && r.TryGetValue("s_value", out v) && k.Length > 0) cfg[k] = v;
}
}
string s;
return cfg.TryGetValue(key, out s) && s.Length > 0 ? s : def;
}
static Color Col(string key, Color def)
{
Color c;
return ColorUtility.TryParseHtmlString(Cfg("color." + key), out c) ? c : def;
}
static Color Hex(string hex, Color def)
{
Color c;
return ColorUtility.TryParseHtmlString(hex, out c) ? c : def;
}
// ---------- 공용 부품 ----------
/// <summary>창 틀(팝업 · 버튼 없음) · 반환 = 판(왼쪽 위 기준 그리기 · 제목 띠 아래 y = 130 부터).</summary>
static RectTransform Panel(OutGameRoot root, string title, float h, string headColor, string last, string heroId)
{
UiText.Use(Texts);
Last = last;
HeroId = heroId;
var content = root.ModalCustom(title, h);
var panel = (RectTransform)content.parent;
var head = panel.Find("Head");
if (head != null && head.GetComponent<Image>() != null && headColor != null) head.GetComponent<Image>().color = Col(headColor, UiKit.Header);
return panel;
}
static Text Txt(RectTransform p, string name, string s, int size, Color c, float x, float y, float w, float h, TextAnchor a = TextAnchor.MiddleLeft, bool title = false)
{
var t = UiKit.Label(p, s, size, c, a, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, -y), new Vector2(w, h), title);
t.name = name;
if (title) UiKit.Title(t, true);
t.horizontalOverflow = HorizontalWrapMode.Overflow;
return t;
}
static Image Box(RectTransform p, string name, float x, float y, float w, float h, Color c, bool raycast = false)
{
return UiKit.Skin(UiKit.At(p, name, x, y, w, h), "card", c, raycast);
}
static Image Ico(RectTransform p, string iconKey, float cx, float cy, float s)
{
var ic = UiKit.Icon(p, Cfg("icon." + iconKey, iconKey), new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(cx, -cy), s);
if (ic != null) UiKit.DropShadow(ic, 2f);
return ic;
}
static Button Btn(RectTransform p, string name, string skin, Color tint, string label, int size, Color fg, float x, float y, float w, float h, Action onClick)
{
return UiKit.SkinBtn(p, name, UISkin.Has(skin) ? skin : "button", tint, label, size, fg, x, y, w, h, onClick);
}
/// <summary>고른 영웅 카드(창 위 · ◀ ▶) — small = 비서 교환 창의 작은 카드(넘김 없음).</summary>
static float HeroCard(OutGameRoot root, RectTransform panel, string id, float y, bool awaken, Action<string> reopen)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var lv = s.Save.Level(id);
var card = Box(panel, "HeroCard", L, y, RW, 200f, Col("card", UiKit.Dark));
var cr = card.rectTransform;
if (reopen != null)
{
foreach (var d in new[] { -1, 1 })
{
int dd = d;
var ar = Box(cr, d < 0 ? "Prev" : "Next", d < 0 ? 12f : RW - 68f, 50f, 56f, 100f, Col("chip", UiKit.Dark), true);
ar.gameObject.AddComponent<Button>().onClick.AddListener(() => reopen(root.HeroDetail.StepHero(dd)));
Ico(ar.rectTransform, d < 0 ? "prev" : "next", 28f, 50f, 40f);
}
}
float x0 = reopen != null ? 84f : 20f;
var pb = Box(cr, "PortraitBox", x0, 16f, 168f, 168f, Col("chip", UiKit.Dark));
if (h != null) UiKit.Portrait("Portrait", pb.rectTransform, h, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(160f, 160f), false, 1f, Color.clear);
if (h == null || hs == null) return y + 216f;
float x = x0 + 186f;
var fb = UiKit.FactionBadge(cr, h.faction, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(x + 24f, -46f), 46f);
if (fb != null) UiKit.DropShadow(fb, 2f);
var ci = UiKit.Icon(cr, UiKit.TypeSymbolId(h.type), new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(x + 80f, -46f), 46f);
if (ci != null) UiKit.DropShadow(ci, 2f);
var gc = UiKit.Skin(UiKit.At(cr, "Grade", x + 112f, 26f, 56f, 42f), "chip", UiKit.GradeColor(hs.grade));
UiKit.GradeTint(gc, hs.grade); // 채 = 7색 순환
UiKit.Title(UiKit.FillLabel(gc.transform, UiKit.GradeKo(hs.grade), 24, UiKit.White), true);
var nm = Txt(cr, "Name", h.nameKo, 40, Col("text", UiKit.White), x + 180f, 20f, 300f, 54f, TextAnchor.MiddleLeft, true);
Txt(cr, "Type", UnitTypeInfo.Korean(h.type), 24, Col("dim", UiKit.InkSoft), x + 190f + nm.preferredWidth, 30f, 120f, 40f);
int max = s.Db.Evolve.MaxStar;
for (int i = 0; i < max; i++) Ico(cr, i < hs.star ? "star_on" : "star_off", x + 22f + i * 52f, 104f, 50f);
Txt(cr, "Lv", F("card_lv", lv.lv.ToString(), AwakenRules.HeroLevelCap(s.Db, s.Save, lv).ToString()), 30, Col("text", UiKit.White), x + max * 52f + 12f, 82f, 220f, 44f, TextAnchor.MiddleLeft, true);
var st = s.StatsOf(id);
var pw = Txt(cr, "Power", F("card_power", N(st.power)), 28, Col("gold", UiKit.Coin), x, 140f, 300f, 42f, TextAnchor.MiddleLeft, true);
if (awaken)
Txt(cr, "AwakenPower", F("card_awaken_power", N(AwakenRules.Power(s.Db, s.Cfg, h, hs, s.Save))), 28, Col("up", UiKit.Ok), x + pw.preferredWidth + 28f, 140f, 300f, 42f, TextAnchor.MiddleLeft, true);
return y + 216f;
}
static string StatText(AwakenDb db, AwakenLine l)
{
var st = db.StatOf(l.stat);
return F("aw_line", st != null ? st.nameKo : l.stat, l.value.ToString("0.0", CultureInfo.InvariantCulture), st != null ? st.unit : "");
}
/// <summary>각성 줄 1개(등급 상자 + 능력치 + 자물쇠) · lockClick = null 이면 자물쇠 없음.</summary>
static void LineRow(RectTransform panel, AwakenDb db, AwakenLine l, int i, float y, Action lockClick)
{
var g = db.GradeOf(l.grade);
var gc = g != null ? Hex(g.color, UiKit.Dark) : Col("closed", UiKit.Dark);
var row = Box(panel, "Line" + i, L, y, RW, 96f, Col("row", UiKit.Dark));
var rr = row.rectTransform;
var gb = Box(rr, "Grade", 0f, 0f, 140f, 96f, gc);
UiKit.Title(UiKit.FillLabel(gb.transform, g != null ? g.nameKo : "-", 52, UiKit.White), true);
var band = UiKit.Skin(UiKit.At(rr, "Band", 140f, 20f, 520f, 56f), "card", new Color(gc.r, gc.g, gc.b, 0.25f));
band.raycastTarget = false;
Txt(rr, "Stat", StatText(db, l), 36, Col("text", UiKit.White), 164f, 20f, 560f, 56f, TextAnchor.MiddleLeft, true);
if (lockClick == null) return;
var lb = Box(rr, "Lock", RW - 96f, 8f, 80f, 80f, l.locked ? Col("lock_on", UiKit.Coin) : Color.clear, true);
lb.gameObject.AddComponent<Button>().onClick.AddListener(() => lockClick());
Ico(lb.rectTransform, l.locked ? "lock_on" : "lock_off", 40f, 40f, l.locked ? 64f : 52f);
}
// ---------- ① 각성 ----------
public static void OpenAwaken(OutGameRoot root, string id)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
if (h == null || hs == null || h.isSoldier || s.Db.Awaken == null)
{
UiText.Use(Texts);
root.Toast(T("aw_none"));
return;
}
s.AwakenSync(id); // 열린 칸 채움(새 칸 무료 굴림)
var db = s.Db.Awaken;
int maxSlots = AwakenRules.MaxSlots(s.Db);
var panel = Panel(root, T("aw_title"), Mathf.Min(1500f, 600f + maxSlots * 108f), null, "awaken", id);
var help = Box(panel, "Help", 40f, 30f, 64f, 64f, Col("chip", UiKit.Dark), true);
help.gameObject.AddComponent<Button>().onClick.AddListener(() => OpenProb(root, id));
Ico(help.rectTransform, "help", 32f, 32f, 46f);
float y = HeroCard(root, panel, id, 132f, true, nid => OpenAwaken(root, nid));
int open = AwakenRules.OpenSlots(s.Db, hs), shown = AwakenRules.Shown(s.Db, hs);
var info = Txt(panel, "Info", F("aw_info", open.ToString(), maxSlots.ToString(), HeroRules.GearSlotCount(s.Db).ToString()), 21, Col("dim", UiKit.InkSoft), L + 4f, y - 4f, 640f, 54f, TextAnchor.MiddleLeft);
info.horizontalOverflow = HorizontalWrapMode.Wrap; // 칩과 겹치지 않게 두 줄까지
var chip = Box(panel, "Stone", W - L - 200f, y - 4f, 200f, 50f, Col("chip", UiKit.Dark));
Ico(chip.rectTransform, "awaken_stone", 30f, 25f, 40f);
Txt(chip.rectTransform, "Have", N(AwakenRules.Goods(s.Save, db.StoneKey)), 28, Col("text", UiKit.White), 58f, 4f, 130f, 42f, TextAnchor.MiddleRight, true);
y += 56f;
for (int i = 0; i < maxSlots; i++)
{
int k = i;
if (i < shown)
LineRow(panel, db, hs.awaken[i], i, y, () =>
{
var why = s.AwakenLock(id, k);
if (why == "lock_last") root.Toast(T("aw_lock_last"));
else if (why != null) root.Toast(why);
OpenAwaken(root, id);
});
else
{
// 닫힌 칸 = 「모든 장비 {s_grade_ko} 등급 시 열림」(awaken_slots · 2차)
var c = Box(panel, "Closed" + i, L, y, RW, 96f, Col("closed", UiKit.Dark));
var t = Txt(c.rectTransform, "Text", F("aw_closed", db.slots[i].nameKo), 30, Col("dim", UiKit.InkSoft), 0f, 24f, RW, 48f, TextAnchor.MiddleCenter, true);
Ico(c.rectTransform, "lock_off", (RW - t.preferredWidth) * 0.5f - 34f, 48f, 44f);
}
y += 108f;
}
// 아래 = 확률(%) · 잠금 수 · 비용 표 · 각성 버튼
y += 8f;
var pc = Box(panel, "ProbBtn", L, y, 96f, 96f, Col("chip", UiKit.Dark), true);
pc.gameObject.AddComponent<Button>().onClick.AddListener(() => OpenProb(root, id));
UiKit.Title(UiKit.FillLabel(pc.transform, "%", 44, UiKit.White), true);
int locks = AwakenRules.Locks(s.Db, hs);
var lk = Txt(panel, "Locks", F("aw_locks", locks.ToString()), 24, Col("text", UiKit.White), L + 116f, y - 4f, 420f, 60f, TextAnchor.MiddleLeft);
lk.horizontalOverflow = HorizontalWrapMode.Wrap;
var list = new List<string>();
foreach (var c in db.costs) list.Add(F("aw_cost_list", c.locks.ToString(), c.stone.ToString()));
var cl = Txt(panel, "CostList", string.Join(" · ", list.ToArray()), 21, Col("dim", UiKit.InkSoft), L + 116f, y + 56f, 420f, 56f, TextAnchor.UpperLeft);
cl.horizontalOverflow = HorizontalWrapMode.Wrap;
int cost = AwakenRules.Cost(s.Db, hs);
var why2 = AwakenRules.CanRoll(s.Db, s.Save, h, hs);
var b = Btn(panel, "Roll", "btn_l_yellow", UiKit.White, T("aw_roll"), 40, UiKit.Col("text_on_yellow", UiKit.Ink), W - L - 300f, y - 6f, 300f, 112f, () => TryRoll(root, id));
UiKit.BtnCost(b, Cfg("icon.awaken_stone", "rank_7"), cost.ToString(), 36f, 30);
if (why2 != null) b.GetComponent<Image>().color = new Color(0.8f, 0.8f, 0.8f, 1f);
}
static void TryRoll(OutGameRoot root, string id)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var why = AwakenRules.CanRoll(s.Db, s.Save, h, hs);
if (why != null)
{
root.Toast(why);
return;
}
var warn = AwakenRules.Warn(s.Db, hs);
if (warn.Count > 0) OpenWarn(root, id, warn);
else DoRoll(root, id);
}
static void DoRoll(OutGameRoot root, string id)
{
var why = root.Session.AwakenRoll(id);
OpenAwaken(root, id);
root.Toast(why ?? T("aw_done"));
}
// ---------- ② 각성 확률 ----------
public static void OpenProb(OutGameRoot root, string id)
{
var s = root.Session;
var db = s.Db.Awaken;
var panel = Panel(root, T("aw_prob_title"), Mathf.Min(1500f, 520f + db.stats.Count * 52f), null, "prob", id);
float y = 132f;
Txt(panel, "GradeHead", T("aw_prob_grade"), 26, Col("gold", UiKit.Coin), L, y, 400f, 40f, TextAnchor.MiddleLeft, true);
y += 46f;
float sum = db.GradeWeightSum, gw = RW / Mathf.Max(1, db.grades.Count);
for (int i = 0; i < db.grades.Count; i++)
{
var g = db.grades[i];
var gb = Box(panel, "G_" + g.grade, L + i * gw + 20f, y, gw - 40f, 56f, Hex(g.color, UiKit.Dark));
UiKit.Title(UiKit.FillLabel(gb.transform, g.nameKo, 32, UiKit.White), true);
Txt(panel, "P_" + g.grade, (g.weight * 100f / Mathf.Max(0.0001f, sum)).ToString("0.#", CultureInfo.InvariantCulture) + "%", 28, Col("text", UiKit.White), L + i * gw, y + 60f, gw, 40f, TextAnchor.MiddleCenter, true);
}
y += 116f;
Txt(panel, "RangeHead", T("aw_prob_range"), 26, Col("gold", UiKit.Coin), L, y, RW, 40f, TextAnchor.MiddleLeft, true);
y += 46f;
float c0 = 220f, cw = (RW - c0) / Mathf.Max(1, db.grades.Count);
var hd = Box(panel, "Head", L, y, RW, 46f, Col("chip", UiKit.Dark));
Txt(hd.rectTransform, "S", T("aw_prob_stat"), 22, Col("text", UiKit.White), 16f, 4f, c0, 38f, TextAnchor.MiddleLeft, true);
for (int i = 0; i < db.grades.Count; i++)
Txt(hd.rectTransform, "G" + i, db.grades[i].nameKo, 22, Hex(db.grades[i].color, UiKit.White), c0 + i * cw, 4f, cw, 38f, TextAnchor.MiddleCenter, true);
y += 50f;
foreach (var st in db.stats)
{
var r = Box(panel, "R_" + st.stat, L, y, RW, 48f, Col("row", UiKit.Dark)).rectTransform;
Txt(r, "S", st.nameKo, 23, Col("text", UiKit.White), 16f, 4f, c0, 40f);
for (int i = 0; i < db.grades.Count && i < st.min.Length; i++)
Txt(r, "V" + i, st.min[i].ToString("0.##", CultureInfo.InvariantCulture) + "–" + st.max[i].ToString("0.##", CultureInfo.InvariantCulture), 22, Col("text", UiKit.White), c0 + i * cw, 4f, cw, 40f, TextAnchor.MiddleCenter);
y += 52f;
}
var note = Txt(panel, "Note", F("aw_prob_note", db.stats.Count.ToString()), 22, Col("dim", UiKit.InkSoft), L, y + 8f, RW, 70f, TextAnchor.UpperLeft);
note.horizontalOverflow = HorizontalWrapMode.Wrap;
}
// ---------- ③ 높은 등급 경고 ----------
static void OpenWarn(OutGameRoot root, string id, List<AwakenLine> lines)
{
var s = root.Session;
var db = s.Db.Awaken;
var panel = Panel(root, T("aw_warn_title"), 520f + lines.Count * 108f, "warn_head", "warn", id);
float y = 136f;
var body = Txt(panel, "Body", F("aw_warn_body", db.Cfg("warn_grade")), 27, Col("text", UiKit.White), L, y, RW, 90f, TextAnchor.UpperCenter);
body.horizontalOverflow = HorizontalWrapMode.Wrap;
y += 100f;
for (int i = 0; i < lines.Count; i++)
{
LineRow(panel, db, lines[i], i, y, null);
y += 108f;
}
Txt(panel, "Hint", T("aw_warn_hint"), 23, Col("dim", UiKit.InkSoft), L, y + 4f, RW, 40f, TextAnchor.MiddleCenter);
y += 56f;
Btn(panel, "Cancel", "btn_s_gray", UiKit.White, T("aw_warn_cancel"), 36, UiKit.White, L, y, 420f, 100f, () => OpenAwaken(root, id));
Btn(panel, "Go", "btn_l_red", UiKit.Red, T("aw_warn_go"), 36, UiKit.White, W - L - 420f, y, 420f, 100f, () => DoRoll(root, id));
}
// ---------- ④ 진화 ----------
static string SkillUnlockText(string v)
{
if (string.IsNullOrEmpty(v) || v == "none") return T("skill_none");
if (v.StartsWith("passive_x")) return F("skill_passive_x", v.Substring("passive_x".Length));
if (v.StartsWith("active_lv+")) return F("skill_active_lv", v.Substring("active_lv+".Length));
return v;
}
static void Change(RectTransform panel, string label, string now, string next, float y)
{
Txt(panel, "C_" + label, label, 27, Col("text", UiKit.White), L + 10f, y, 300f, 44f);
Txt(panel, "N_" + label, now, 27, Col("text", UiKit.White), L + 380f, y, 200f, 44f, TextAnchor.MiddleRight);
Txt(panel, "A_" + label, "→", 27, Col("dim", UiKit.InkSoft), L + 600f, y, 40f, 44f, TextAnchor.MiddleCenter);
Txt(panel, "X_" + label, next, 27, Col("up", UiKit.Ok), L + 650f, y, 220f, 44f, TextAnchor.MiddleLeft, true);
}
public static void OpenEvolve(OutGameRoot root, string id)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
if (h == null || hs == null || h.isSoldier || s.Db.Awaken == null)
{
UiText.Use(Texts);
root.Toast(T("ev_none"));
return;
}
var db = s.Db;
const float EvH = 1210f;
var panel = Panel(root, T("ev_title"), EvH, null, "evolve", id);
float y = HeroCard(root, panel, id, 132f, false, nid => OpenEvolve(root, nid));
var next = AwakenRules.NextRow(db, hs);
var now = db.Evolve.Get(hs.star);
int max = db.Evolve.MaxStar;
// 별 줄 = 지금 → 다음
for (int i = 0; i < max; i++) Ico(panel, i < hs.star ? "star_on" : "star_off", L + 60f + i * 50f, y + 30f, 46f);
Txt(panel, "Now", F("ev_now", hs.star.ToString()), 22, Col("dim", UiKit.InkSoft), L + 40f, y + 56f, 260f, 34f, TextAnchor.MiddleCenter);
if (next != null)
{
Txt(panel, "Arrow", "→", 40, Col("dim", UiKit.InkSoft), L + 380f, y + 6f, 60f, 50f, TextAnchor.MiddleCenter, true);
for (int i = 0; i < max; i++) Ico(panel, i < next.star ? "star_on" : "star_off", L + 500f + i * 50f, y + 30f, 46f);
Txt(panel, "Next", F("ev_next", next.star.ToString()), 22, Col("up", UiKit.Ok), L + 480f, y + 56f, 260f, 34f, TextAnchor.MiddleCenter, true);
}
y += 104f;
if (next != null)
{
Txt(panel, "Changes", T("ev_changes"), 25, Col("gold", UiKit.Coin), L, y, 300f, 40f, TextAnchor.MiddleLeft, true);
y += 46f;
Change(panel, T("ev_maxlv"), "Lv " + now.maxLv, "Lv " + next.maxLv, y);
y += 50f;
Change(panel, T("ev_star_pct"), F("ev_pct", now.starPct.ToString("0.#", CultureInfo.InvariantCulture)), F("ev_pct", next.starPct.ToString("0.#", CultureInfo.InvariantCulture)), y);
y += 50f;
Change(panel, T("ev_skill"), T("skill_none"), SkillUnlockText(next.skillUnlock), y);
y += 62f;
Txt(panel, "Need", T("ev_need"), 25, Col("gold", UiKit.Coin), L, y, 300f, 40f, TextAnchor.MiddleLeft, true);
y += 46f;
// 최대 레벨 도달
int cap = AwakenRules.StarMaxLv(db, hs.star);
var r1 = Box(panel, "NeedLv", L, y, RW, 100f, Col("row", UiKit.Dark)).rectTransform;
var lvb = Box(r1, "Badge", 16f, 14f, 72f, 72f, Col("card", UiKit.Dark));
UiKit.Title(UiKit.FillLabel(lvb.transform, "Lv", 30, UiKit.White), true);
Txt(r1, "T", T("ev_need_lv"), 28, Col("text", UiKit.White), 108f, 12f, 400f, 42f, TextAnchor.MiddleLeft, true);
Txt(r1, "S", F("ev_need_lv_sub", hs.star.ToString(), cap.ToString()), 21, Col("dim", UiKit.InkSoft), 108f, 54f, 400f, 34f);
bool lvOk = hs.lv >= cap;
Txt(r1, "V", "Lv " + hs.lv + " / " + cap, 28, lvOk ? Col("up", UiKit.Ok) : Col("text", UiKit.White), 520f, 28f, 260f, 44f, TextAnchor.MiddleRight, true);
if (lvOk) Ico(r1, "check", RW - 50f, 50f, 46f);
y += 110f;
// 진영 비서
var it = AwakenRules.EvolveItem(db, h, hs);
var r2 = Box(panel, "NeedItem", L, y, RW, 100f, Col("row", UiKit.Dark)).rectTransform;
var ib = Box(r2, "Icon", 16f, 14f, 72f, 72f, Col("card", UiKit.Dark));
Ico(ib.rectTransform, "tome", 36f, 36f, 60f);
int have = it != null ? AwakenRules.Goods(s.Save, it.key) : 0;
Txt(r2, "T", it != null ? it.nameKo : "-", 28, Col("text", UiKit.White), 108f, 12f, 420f, 42f, TextAnchor.MiddleLeft, true);
Txt(r2, "S", F("ev_item_sub", T("faction_" + h.faction)), 21, Col("dim", UiKit.InkSoft), 108f, 54f, 420f, 34f);
Txt(r2, "V", have + " / " + next.item, 30, have >= next.item ? Col("up", UiKit.Ok) : UiKit.Red, 520f, 28f, 120f, 44f, TextAnchor.MiddleRight, true);
Btn(r2, "Get", "btn_sky", UiKit.White, T("ev_get"), 28, UiKit.White, RW - 170f, 20f, 150f, 62f, () => OpenShop(root, id, h.faction));
y += 110f;
// 골드
var r3 = Box(panel, "NeedGold", L, y, RW, 90f, Col("row", UiKit.Dark)).rectTransform;
Ico(r3, "gold", 52f, 45f, 60f);
Txt(r3, "T", T("ev_gold"), 28, Col("text", UiKit.White), 108f, 22f, 300f, 46f, TextAnchor.MiddleLeft, true);
Txt(r3, "V", N(next.gold), 30, s.Save.gold >= next.gold ? Col("text", UiKit.White) : UiKit.Red, RW - 320f, 22f, 300f, 46f, TextAnchor.MiddleRight, true);
y += 110f;
}
var why = AwakenRules.CanEvolve(db, s.Save, h, hs);
string label = next == null ? T("ev_top") : why == null ? T("ev_go") : T("ev_lack");
var b = Btn(panel, "Go", why == null ? "btn_l_yellow" : "btn_s_gray", UiKit.White, label, 40, why == null ? UiKit.Col("text_on_yellow", UiKit.Ink) : UiKit.White, (W - 420f) * 0.5f, Mathf.Max(y, EvH - 150f), 420f, 104f, () =>
{
var w = root.HeroDetail.DoEvolve(id);
if (w != null)
{
root.Toast(w);
return;
}
OpenDone(root, id);
});
b.interactable = next != null; // 재료 부족 = 눌러서 사유 토스트 · 최고 ★ = 꺼짐
}
// ---------- ⑤ 진화 완료 ----------
static void OpenDone(OutGameRoot root, string id)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var db = s.Db;
var panel = Panel(root, T("ev_done_title"), 680f, "done_head", "done", id);
float y = 140f;
int max = db.Evolve.MaxStar;
for (int i = 0; i < max; i++) Ico(panel, i < hs.star ? "star_on" : "star_off", W * 0.5f + (i - (max - 1) * 0.5f) * 70f, y + 36f, 66f);
y += 84f;
Txt(panel, "Head", F("ev_done_head", h.nameKo, hs.star.ToString()), 44, Col("gold", UiKit.Coin), L, y, RW, 60f, TextAnchor.MiddleCenter, true);
y += 60f;
Txt(panel, "Sub", T(hs.star >= max ? "ev_done_top" : "ev_done_up"), 24, Col("dim", UiKit.InkSoft), L, y, RW, 36f, TextAnchor.MiddleCenter);
y += 54f;
var prev = db.Evolve.Get(hs.star - 1);
var now = db.Evolve.Get(hs.star);
if (prev != null && now != null)
{
Change(panel, T("ev_maxlv"), "Lv " + prev.maxLv, "Lv " + now.maxLv, y);
y += 50f;
Change(panel, T("ev_star_pct"), F("ev_pct", prev.starPct.ToString("0.#", CultureInfo.InvariantCulture)), F("ev_pct", now.starPct.ToString("0.#", CultureInfo.InvariantCulture)), y);
y += 50f;
Change(panel, T("ev_skill"), T("skill_none"), SkillUnlockText(now.skillUnlock), y);
y += 62f;
}
y += 10f;
Btn(panel, "Ok", "btn_l_yellow", UiKit.White, T("ev_done_ok"), 36, UiKit.Col("text_on_yellow", UiKit.Ink), (W - 420f) * 0.5f, y, 420f, 100f, root.CloseModal);
}
// ---------- ⑦ 각성 칸 열림(2차 §5-1 · 목업 07) ----------
/// <summary>6칸째 장비로 각성 칸이 열린 순간 — 그 칸 줄(무료 1회 결과 · 또는 보관했던 줄) · 닫기 / 각성하러 가기.</summary>
public static void OpenSlotOpen(OutGameRoot root, string id, int idx, bool fresh)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var db = s.Db.Awaken;
if (h == null || hs == null || db == null || idx < 0 || idx >= hs.awaken.Count || idx >= db.slots.Count) return;
var panel = Panel(root, T("aw_open_title"), 560f, "done_head", "slot_open", id);
float y = 140f;
string grade = "<color=#" + ColorUtility.ToHtmlStringRGB(Col("gold", UiKit.Coin)) + ">" + F("aw_open_grade", db.slots[idx].nameKo) + "</color>";
Txt(panel, "Head", F("aw_open_head", grade), 34, Col("text", UiKit.White), L, y, RW, 50f, TextAnchor.MiddleCenter, true).supportRichText = true;
y += 54f;
Txt(panel, "Sub", F(fresh ? "aw_open_sub" : "aw_open_sub_kept", h.nameKo, (idx + 1).ToString(), db.slots.Count.ToString()), 24, Col("dim", UiKit.InkSoft), L, y, RW, 36f, TextAnchor.MiddleCenter);
y += 54f;
LineRow(panel, db, hs.awaken[idx], idx, y, () =>
{
var why = s.AwakenLock(id, idx);
if (why == "lock_last") root.Toast(T("aw_lock_last"));
else if (why != null) root.Toast(why);
OpenSlotOpen(root, id, idx, fresh);
});
y += 112f;
Txt(panel, "Note", T("aw_open_note"), 22, Col("dim", UiKit.InkSoft), L, y, RW, 34f, TextAnchor.MiddleCenter);
y += 52f;
Btn(panel, "Close", "btn_s_gray", UiKit.White, T("aw_open_close"), 34, UiKit.White, L + 120f, y, 280f, 96f, root.CloseModal);
Btn(panel, "Awaken", "btn_l_yellow", UiKit.White, T("aw_open_go"), 34, UiKit.Col("text_on_yellow", UiKit.Ink), L + 420f, y, 340f, 96f, () => OpenAwaken(root, id));
}
// ---------- ⑧ 스킬 강화(2차 §5-2 · 목업 08) ----------
/// <summary>만능 조각 표시(목업 = 보라 「만」 글자 · 같은 그림 없음) — 중심 (x, y) · 크기 s.</summary>
static Text Glyph(RectTransform p, string name, float x, float y, float s)
{
return Txt(p, name, T("univ_glyph"), (int)(s * 0.62f), Col("univ", UiKit.White), x - s * 0.5f, y - s * 0.5f, s, s, TextAnchor.MiddleCenter, true);
}
/// <summary>스킬 강화 창 — 고른 영웅 카드(◀ ▶) · 영웅 조각 · 만능 조각 보유 · 액티브 · 패시브 줄(레벨 · 조건 · 효과 · 조각 보유 / 필요 · 강화).</summary>
public static void OpenSkill(OutGameRoot root, string id)
{
var s = root.Session;
var h = s.Def(id);
var hs = s.Save.Hero(id);
if (h == null || hs == null || h.isSoldier || s.Db.Awaken == null)
{
UiText.Use(Texts);
root.Toast(T("sk_none"));
return;
}
var db = s.Db;
var aw = db.Awaken;
var panel = Panel(root, T("sk_title"), 1000f, null, "skill", id);
var help = Box(panel, "Help", 300f, 30f, 64f, 64f, Col("chip", UiKit.Dark), true);
help.gameObject.AddComponent<Button>().onClick.AddListener(() => root.Toast(T("sk_help")));
Ico(help.rectTransform, "help", 32f, 32f, 46f);
float y = HeroCard(root, panel, id, 132f, false, nid => OpenSkill(root, nid));
// 안내(표 값) + 보유 칩 2개
var costs = new List<string>();
int topLv = SkillRules.MaxLv(db, h, 0), sum = 0;
foreach (var st in aw.skillSteps)
{
costs.Add(st.shard.ToString());
if (st.to <= topLv) sum += st.shard;
}
var info = Txt(panel, "Info", F("sk_info", h.nameKo, string.Join(" · ", costs.ToArray()), topLv.ToString(), sum.ToString()), 21, Col("dim", UiKit.InkSoft), L + 4f, y - 4f, 600f, 110f, TextAnchor.UpperLeft);
info.horizontalOverflow = HorizontalWrapMode.Wrap;
int univHave = AwakenRules.Goods(s.Save, aw.UnivKey);
var c1 = Box(panel, "HeroShard", W - L - 290f, y + 20f, 160f, 54f, Col("chip", UiKit.Dark));
Ico(c1.rectTransform, "shard", 30f, 27f, 42f);
Txt(c1.rectTransform, "Have", F("sk_chip_hero", h.nameKo, hs.shards.ToString()), 26, Col("text", UiKit.White), 56f, 6f, 100f, 42f, TextAnchor.MiddleLeft, true);
var c2 = Box(panel, "Univ", W - L - 116f, y + 20f, 116f, 54f, Col("chip", UiKit.Dark));
Glyph(c2.rectTransform, "Glyph", 28f, 27f, 40f);
Txt(c2.rectTransform, "Have", N(univHave), 26, Col("text", UiKit.White), 50f, 6f, 56f, 42f, TextAnchor.MiddleRight, true);
y += 124f;
for (int i = 0; i < 2; i++)
{
SkillRow(root, panel, id, i, y);
y += 228f;
}
}
static void SkillRow(OutGameRoot root, RectTransform panel, string id, int i, float y)
{
var s = root.Session;
var db = s.Db;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var sk = SkillRules.Skill(db, h, i);
var row = Box(panel, "Skill" + i, L, y, RW, 212f, Col("row", UiKit.Dark)).rectTransform;
if (sk == null) return;
// 아이콘(테마 skill_<id> · 없으면 병종 기호)
var ib = Box(row, "Icon", 24f, 46f, 120f, 120f, Col("card", UiKit.Dark));
string iconId = "skill_" + sk.id;
bool hasIcon = UISkin.Theme != null && UISkin.Theme.IconEntryOf(iconId) != null;
Ico(ib.rectTransform, hasIcon ? iconId : UiKit.TypeSymbolId(h.type), 60f, 60f, hasIcon ? 112f : 80f);
var badge = UiKit.Skin(UiKit.At(row, "Kind", 166f, 34f, 92f, 42f), "chip", Col(i == 0 ? "active" : "passive", UiKit.Red));
UiKit.Title(UiKit.FillLabel(badge.transform, T(i == 0 ? "sk_active" : "sk_passive"), 22, UiKit.White), true);
Txt(row, "Name", sk.nameKo, 34, Col("text", UiKit.White), 272f, 30f, 340f, 50f, TextAnchor.MiddleLeft, true);
int lv = SkillRules.Level(hs, i), max = SkillRules.MaxLv(db, h, i);
bool top = lv >= max;
string up = "<color=#" + ColorUtility.ToHtmlStringRGB(Col("up", UiKit.Ok)) + ">";
string lvText = F("sk_lv", lv.ToString(), max.ToString()) + (top ? "" : " " + up + F("sk_lv_next", (lv + 1).ToString()) + "</color>");
Txt(row, "Lv", lvText, 30, Col("text", UiKit.White), 166f, 88f, 440f, 46f, TextAnchor.MiddleLeft, true).supportRichText = true;
var def = SkillCatalog.Get(sk.id);
float f0 = def != null ? def.LevelFactor(lv) : 1f, f1 = def != null ? def.LevelFactor(lv + 1) : 1f;
string cond;
if (top) cond = F("sk_max_cond", f0.ToString("0.0#", CultureInfo.InvariantCulture));
else
{
int needLv = SkillRules.NeedHeroLv(db, hs, i);
bool lvOk = lv < SkillRules.Cap(db, h, hs, i);
string c = "<color=#" + ColorUtility.ToHtmlStringRGB(lvOk ? Col("up", UiKit.Ok) : UiKit.Red) + ">" + F("sk_cond_lv", needLv.ToString()) + " " + T(lvOk ? "sk_ok" : "sk_no") + "</color>";
cond = F("sk_cond", c, f0.ToString("0.0#", CultureInfo.InvariantCulture), f1.ToString("0.0#", CultureInfo.InvariantCulture));
}
Txt(row, "Cond", cond, 22, Col("dim", UiKit.InkSoft), 166f, 140f, 460f, 40f, TextAnchor.MiddleLeft).supportRichText = true;
// 오른쪽 = 조각 보유 / 필요 · 안내 · 강화 버튼
const float RX = 620f, RWd = 232f;
if (top)
{
Txt(row, "Top", T("sk_max"), 30, Col("gold", UiKit.Coin), RX, 80f, RWd, 50f, TextAnchor.MiddleCenter, true);
return;
}
int need, hero, univ;
SkillRules.Plan(db, s.Save, hs, i, out need, out hero, out univ);
int univHave = AwakenRules.Goods(s.Save, db.Awaken.UnivKey);
var why = SkillRules.CanLevelUp(db, s.Save, h, hs, i);
bool capped = lv >= SkillRules.Cap(db, h, hs, i);
bool lack = univ > univHave;
var have = Txt(row, "Have", hs.shards + " / " + need, 30, hs.shards >= need ? Col("up", UiKit.Ok) : UiKit.Red, RX + 60f, 20f, 160f, 46f, TextAnchor.MiddleLeft, true);
Ico(row, "shard", RX + 60f - 26f, 43f, 40f);
string sub = lack ? T("sk_lack") : univ > 0 ? F("sk_fill", univ.ToString()) : F("sk_hero_shard", h.nameKo);
Txt(row, "Sub", sub, 21, lack ? UiKit.Red : univ > 0 ? Col("gold", UiKit.Coin) : Col("dim", UiKit.InkSoft), RX, 64f, RWd, 34f, TextAnchor.MiddleCenter, true);
string label = capped ? F("sk_need_lv", SkillRules.NeedHeroLv(db, hs, i).ToString()) : lack ? T("sk_lack") : T("sk_go");
string skin = why != null ? "btn_s_gray" : univ > 0 ? "btn_purple" : "btn_l_yellow";
Color fg = why == null && univ == 0 ? UiKit.Col("text_on_yellow", UiKit.Ink) : UiKit.White;
int k = i;
Btn(row, "Go", skin, UiKit.White, label, capped ? 24 : 32, fg, RX + 16f, 106f, RWd - 32f, 84f, () => TrySkillUp(root, id, k));
}
static void TrySkillUp(OutGameRoot root, string id, int i)
{
var r = root.HeroDetail.DoSkillUp(id, i, false);
if (r == SkillRules.NeedUniv)
{
OpenSkillUniv(root, id, i);
return;
}
SkillDone(root, id, i, r);
}
static void SkillDone(OutGameRoot root, string id, int i, string r)
{
var s = root.Session;
var sk = SkillRules.Skill(s.Db, s.Def(id), i);
OpenSkill(root, id);
root.Toast(r ?? F("sk_done", sk != null ? sk.nameKo : "", SkillRules.Level(s.Save.Hero(id), i).ToString()));
}
// ---------- ⑨ 만능 조각 확인(2차 §5-2-3 · 목업 09) ----------
public static void OpenSkillUniv(OutGameRoot root, string id, int i)
{
var s = root.Session;
var db = s.Db;
var h = s.Def(id);
var hs = s.Save.Hero(id);
var sk = SkillRules.Skill(db, h, i);
if (h == null || hs == null || sk == null) return;
int need, hero, univ;
SkillRules.Plan(db, s.Save, hs, i, out need, out hero, out univ);
int univHave = AwakenRules.Goods(s.Save, db.Awaken.UnivKey);
int lv = SkillRules.Level(hs, i);
var panel = Panel(root, T("sk_univ_title"), 600f, "univ_head", "skill_univ", id);
float y = 136f;
Txt(panel, "L1", F("sk_univ_l1", sk.nameKo, lv.ToString(), (lv + 1).ToString(), need.ToString()), 28, Col("text", UiKit.White), L, y, RW, 44f, TextAnchor.MiddleCenter, true);
y += 46f;
string n = "<color=#" + ColorUtility.ToHtmlStringRGB(UiKit.Red) + ">" + F("sk_univ_n", univ.ToString()) + "</color>";
Txt(panel, "L2", F("sk_univ_l2", h.nameKo, n), 28, Col("text", UiKit.White), L, y, RW, 44f, TextAnchor.MiddleCenter, true).supportRichText = true;
y += 62f;
var tb = Box(panel, "Table", L, y, RW, 156f, Col("row", UiKit.Dark)).rectTransform;
for (int r = 0; r < 2; r++)
{
float ry = 12f + r * 72f;
if (r == 0) Ico(tb, "shard", 46f, ry + 30f, 40f);
else Glyph(tb, "Glyph", 46f, ry + 30f, 40f);
Txt(tb, "Name" + r, r == 0 ? F("sk_univ_hero", h.nameKo) : T("sk_univ_univ"), 26, Col("text", UiKit.White), 82f, ry + 8f, 320f, 44f, TextAnchor.MiddleLeft, true);
int from = r == 0 ? hs.shards : univHave, use = r == 0 ? hero : univ;
Txt(tb, "Flow" + r, from + " → " + (from - use), 26, Col("text", UiKit.White), 460f, ry + 8f, 240f, 44f, TextAnchor.MiddleRight, true);
Txt(tb, "Use" + r, "−" + use, 26, Col("minus", UiKit.Coin), RW - 140f, ry + 8f, 120f, 44f, TextAnchor.MiddleRight, true);
}
y += 170f;
Txt(panel, "Note", T("sk_univ_note"), 22, Col("dim", UiKit.InkSoft), L, y, RW, 34f, TextAnchor.MiddleCenter);
y += 50f;
Btn(panel, "Cancel", "btn_s_gray", UiKit.White, T("sk_univ_cancel"), 36, UiKit.White, L, y, 420f, 96f, () => OpenSkill(root, id));
Btn(panel, "Go", "btn_purple", UiKit.White, T("sk_univ_go"), 36, UiKit.White, W - L - 420f, y, 420f, 96f, () => SkillDone(root, id, i, root.HeroDetail.DoSkillUp(id, i, true)));
}
// ---------- ⑥ 비서 교환 ----------
public static void OpenShop(OutGameRoot root, string id, string faction)
{
var s = root.Session;
var db = s.Db;
var aw = db.Awaken;
if (aw == null) return;
var h = s.Def(id);
var hs = s.Save.Hero(id);
if (string.IsNullOrEmpty(faction)) faction = h != null ? h.faction : aw.Factions[0];
if (shopFaction != faction) shopPick = null;
shopFaction = faction;
const float ShopH = 1420f;
var panel = Panel(root, T("ev_shop_title"), ShopH, null, "shop", id);
float y = 132f;
// 진영 탭
var facs = aw.Factions;
float tw = RW / Mathf.Max(1, facs.Count);
for (int i = 0; i < facs.Count; i++)
{
string f = facs[i];
var tb = Box(panel, "Tab_" + f, L + i * tw + 4f, y, tw - 8f, 58f, f == faction ? Col("tab_on", UiKit.Ok) : Col("tab_off", UiKit.Dark), true);
tb.gameObject.AddComponent<Button>().onClick.AddListener(() => OpenShop(root, id, f));
UiKit.Title(UiKit.FillLabel(tb.transform, T("faction_" + f), 28, UiKit.White), true);
}
y += 70f;
// 작은 카드 = 고른 영웅 + 다음 진화 재료 보유 / 필요
var card = Box(panel, "SmallCard", L, y, RW, 100f, Col("card", UiKit.Dark)).rectTransform;
if (h != null && hs != null)
{
var pb = Box(card, "PortraitBox", 10f, 8f, 84f, 84f, Col("chip", UiKit.Dark));
UiKit.Portrait("Portrait", pb.rectTransform, h, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(80f, 80f), false, 1f, Color.clear);
Txt(card, "Name", h.nameKo + " ★" + hs.star, 30, Col("text", UiKit.White), 110f, 10f, 360f, 44f, TextAnchor.MiddleLeft, true);
var lvc = s.Save.Level(id);
Txt(card, "Lv", F("card_lv", lvc.lv.ToString(), AwakenRules.HeroLevelCap(db, s.Save, lvc).ToString()), 24, Col("dim", UiKit.InkSoft), 110f, 54f, 300f, 36f);
var it0 = AwakenRules.EvolveItem(db, h, hs);
var nx = AwakenRules.NextRow(db, hs);
Txt(card, "NextHead", T("shop_next"), 22, Col("dim", UiKit.InkSoft), RW - 360f, 10f, 340f, 36f, TextAnchor.MiddleRight);
Txt(card, "NextItem", it0 != null && nx != null ? it0.nameKo + " " + AwakenRules.Goods(s.Save, it0.key) + " / " + nx.item : T("ev_top"), 26, Col("gold", UiKit.Coin), RW - 360f, 50f, 340f, 40f, TextAnchor.MiddleRight, true);
}
y += 112f;
DayOfWeek dow;
int hour;
MissionRules.ParseWeekly(aw.EvCfg("shop_reset"), out dow, out hour);
string day = T("day_" + dow.ToString().Substring(0, 3));
var info = Txt(panel, "Info", F("shop_info", day, hour.ToString()), 21, Col("dim", UiKit.InkSoft), L, y, 520f, 60f, TextAnchor.UpperLeft);
info.horizontalOverflow = HorizontalWrapMode.Wrap;
int spare = 0;
foreach (var sp in AwakenRules.Spares(db, s.Save, faction)) spare += sp.Spare;
var c1 = Box(panel, "Spare", L + 540f, y, 190f, 48f, Col("chip", UiKit.Dark)).rectTransform;
Txt(c1, "T", F("shop_spare", N(spare)), 22, Col("text", UiKit.White), 12f, 4f, 170f, 40f, TextAnchor.MiddleCenter, true);
var c2 = Box(panel, "Point", L + 742f, y, 130f, 48f, Col("chip", UiKit.Dark)).rectTransform;
Txt(c2, "T", F("shop_point", N(AwakenRules.Goods(s.Save, aw.PointKey))), 22, Col("text", UiKit.White), 8f, 4f, 116f, 40f, TextAnchor.MiddleCenter, true);
y += 70f;
// 비서 줄(등급 순)
var items = new List<AwakenDb.Item>();
foreach (var x in aw.items)
if (x.faction == faction) items.Add(x);
items.Sort((a, b) => a.tier.CompareTo(b.tier));
foreach (var it in items)
{
var item = it;
var row = Box(panel, "Item_" + it.key, L, y, RW, 112f, shopPick == it.key ? Col("card", UiKit.Dark) : Col("row", UiKit.Dark)).rectTransform;
var ib = Box(row, "Icon", 12f, 16f, 80f, 80f, Col("card", UiKit.Dark));
Ico(ib.rectTransform, "tome", 40f, 40f, 64f);
Txt(row, "Name", it.nameKo, 28, Col("text", UiKit.White), 108f, 10f, 360f, 42f, TextAnchor.MiddleLeft, true);
int from = 0;
foreach (var r in db.Evolve.rows)
if (r.tier == it.tier) from = r.star - 1;
int left = AwakenRules.Left(db, s.Save, it, s.Now);
var sub = Txt(row, "Sub", F("shop_row_sub", from.ToString(), (from + 1).ToString(), AwakenRules.Goods(s.Save, it.key).ToString(), left.ToString(), it.weekLimit.ToString()), 20, Col("dim", UiKit.InkSoft), 108f, 54f, 400f, 50f, TextAnchor.UpperLeft);
sub.horizontalOverflow = HorizontalWrapMode.Wrap;
if (left <= 0)
{
var done = Box(row, "Done", RW - 330f, 26f, 310f, 60f, Col("chip", UiKit.Dark));
UiKit.Title(UiKit.FillLabel(done.transform, F("shop_week_done", day, hour.ToString()), 22, Col("dim", UiKit.InkSoft)), true);
}
else
{
Btn(row, "ByShard", "btn_sky", Col("shard_btn", UiKit.Jade), F("shop_by_shard", it.priceShard.ToString()), 22, UiKit.White, RW - 330f, 22f, 150f, 68f, () =>
{
shopPick = item.key;
OpenShop(root, id, faction);
});
Btn(row, "ByPoint", "btn_purple", Col("point_btn", UiKit.Purple), F("shop_by_point", it.pricePoint.ToString()), 22, UiKit.White, RW - 170f, 22f, 150f, 68f, () =>
{
var w = s.TomeExchange(item, true);
root.Toast(w ?? F("shop_got", item.nameKo));
OpenShop(root, id, faction);
});
}
y += 122f;
}
// 조각 고르기(고른 비서)
var pick = shopPick != null ? aw.ItemByKey(shopPick) : null;
if (pick != null)
{
Txt(panel, "PickHead", F("shop_pick_title", pick.nameKo, pick.priceShard.ToString()), 24, Col("gold", UiKit.Coin), L, y, RW, 40f, TextAnchor.MiddleLeft, true);
y += 44f;
bool warn;
var plan = AwakenRules.PickShards(db, s.Save, faction, pick.priceShard, out warn);
int shown = 0;
foreach (var sp in AwakenRules.Spares(db, s.Save, faction))
{
if (shown >= 4) break;
var pr = Box(panel, "Pick_" + sp.h.id, L, y, RW, 50f, Col("row", UiKit.Dark)).rectTransform;
Txt(pr, "N", sp.h.nameKo, 23, Col("text", UiKit.White), 16f, 6f, 160f, 38f, TextAnchor.MiddleLeft, true);
Txt(pr, "O", F("shop_pick_row", sp.owned.ToString()), 21, Col("dim", UiKit.InkSoft), 180f, 6f, 160f, 38f);
Txt(pr, "D", F("shop_pick_need", sp.need.ToString()), 21, Col("dim", UiKit.InkSoft), 350f, 6f, 200f, 38f);
Txt(pr, "S", F("shop_pick_spare", sp.Spare.ToString()), 21, Col("up", UiKit.Ok), 560f, 6f, 180f, 38f, TextAnchor.MiddleLeft, true);
int take = 0;
if (plan != null)
foreach (var kv in plan)
if (kv.Key == sp.s) take = kv.Value;
if (take > 0) Txt(pr, "T", "-" + take, 23, warn ? UiKit.Red : Col("gold", UiKit.Coin), RW - 110f, 6f, 90f, 38f, TextAnchor.MiddleRight, true);
y += 56f;
shown++;
}
}
var foot = Txt(panel, "Foot", T("shop_pick_note"), 21, Col("dim", UiKit.InkSoft), L, ShopH - 150f, 480f, 70f, TextAnchor.UpperLeft);
foot.horizontalOverflow = HorizontalWrapMode.Wrap;
var go = Btn(panel, "Exchange", "btn_l_yellow", UiKit.White, T("shop_go"), 38, UiKit.Col("text_on_yellow", UiKit.Ink), W - L - 340f, ShopH - 160f, 340f, 100f, () =>
{
var it = shopPick != null ? aw.ItemByKey(shopPick) : null;
if (it == null) return;
bool warn;
var plan = AwakenRules.PickShards(db, s.Save, it.faction, it.priceShard, out warn);
Action doIt = () =>
{
var w = s.TomeExchange(it, false);
root.Toast(w ?? F("shop_got", it.nameKo));
OpenShop(root, id, faction);
};
if (plan != null && warn)
root.Modal(T("ev_shop_title"), T("shop_warn"), new OutGameRoot.ModalButton(T("aw_warn_cancel"), UiKit.Dark, () => OpenShop(root, id, faction)), new OutGameRoot.ModalButton(T("shop_go"), UiKit.Red, doIt));
else doIt();
});
go.interactable = pick != null;
}
}
}