ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Arena/ArenaRaid.cs

912 lines
46 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 맹장 토벌전 화면(PD 2026-11-18 「맹장 토벌전 메뉴가 제대로 보여지지 않고 있어 … 정상적으로 게임에서 확인할 수 있도록 반영해줘」 · 아트 시안 content_screens_2/raid_banner/final/mock_raid.png) —
/// 탭(토벌 · 순위 · 훈장 상점) + 메인 맹장 카드(배너 · 태그 · 이름 · 칭호 · 군령 · 교대 · 맹장/패턴/약점 칸 · 오늘 기록 · 넘김 · 상세 정보 · 도전) + 서브 맹장 카드(연습 · 도전) + 주간 점수 띠(순위 · 내역 · 누적 단계 상자).
/// 기능 = 예전 더미 화면(ArenaScreen.BuildRaid2)과 같음: 맹장 = RaidRules.BossOf · 도전 · 연습 = ArenaScreen.RaidGo · 상점 구매 = ArenaScreen.RaidBuyPick · 순위 표 = Net.RankPanel(서버 모드) · 해금 전 = 같은 화면(도전 = 잠김 버튼) + 화면 위 잠김 덮개(LockOverlay · ArenaScreen.ShowRaidView · PD 2026-11-18).
/// 표(C45): 화면 = Resources/UI/Raid/raid_screen(키 · 값 · 배치 · 색 · 시안 예시 값) · 글자 = raid_text(UiText) · 맹장 값 = 게임 표 ContentModes/raid_*(RaidData) · 배너 = ContentModes/Art/raid_banner_&lt;id&gt;.
/// 층(P41): 화면 → 본문 맞춤(UiFitHeight) → Art(카드 테 · 배너 · 점수 띠 바탕 · Static) · Info(값 · 탭 · 버튼 · 누름 칸 · Event + 레이캐스터) · Clock(교대 남은 시간 · 1초마다 · Frame).
/// 게임에 데이터가 없는 값(오늘 기록 · 기기 세이브의 순위)은 설정 표 example_* (시안 예시 값) — 투기장 화면과 같은 방식.
/// </summary>
public class ArenaRaid
{
public const string Table = "UI/Raid/raid_screen";
readonly ArenaScreen screen;
readonly Dictionary<string, List<string>> kv = new Dictionary<string, List<string>>();
readonly Dictionary<string, string[]> bosses = new Dictionary<string, string[]>();
readonly Dictionary<string, string[]> btns = new Dictionary<string, string[]>();
readonly Dictionary<string, Text> texts = new Dictionary<string, Text>();
readonly Dictionary<string, Button> buttons = new Dictionary<string, Button>();
public RectTransform View { get; private set; }
public RectTransform Design { get; private set; }
public RectTransform Art { get; private set; }
public RectTransform Info { get; private set; }
public RectTransform Clock { get; private set; }
public bool Built { get; private set; }
public bool Locked { get; private set; }
/// <summary>지금 탭 동작(raid · shop).</summary>
public string Tab { get; private set; }
/// <summary>메인 카드 넘김(0 = 이번 주 · k = k 주 뒤 메인 미리 보기).</summary>
public int Preview { get; private set; }
public string MainId { get; private set; }
public string SubId { get; private set; }
public string ShownMainId { get; private set; }
public int CardCount { get; private set; }
public int TileCount { get; private set; }
public int ShopRows { get; private set; }
/// <summary>마지막으로 연 상세 정보 창의 맹장(테스트).</summary>
public string LastDetail { get; private set; }
DateTime mainEnd = DateTime.MaxValue, subEnd = DateTime.MaxValue; // 현지 시각
string nextMainName = "", nextSubName = "";
Text mainClock, subClock;
Color strokeC = Color.black;
float strokeW = 3f;
ArenaRaid(ArenaScreen s)
{
screen = s;
Tab = "raid";
}
OutGameSession S
{
get { return screen.S; }
}
// ---------- 표 ----------
/// <summary>설정 표 · 글자 표를 읽는다(그림은 처음 열 때 Show) · 표가 없으면 null(호출 쪽 = 예전 더미 화면).</summary>
public static ArenaRaid Load(ArenaScreen s)
{
var rows = UiText.Rows(Table);
if (rows == null) return null;
var rd = new ArenaRaid(s);
foreach (var r in rows)
{
string k, v;
if (!r.TryGetValue("s_key", out k) || k.Length == 0) continue;
r.TryGetValue("s_value", out v);
List<string> l;
if (!rd.kv.TryGetValue(k, out l)) rd.kv[k] = l = new List<string>();
l.Add(v ?? "");
}
foreach (var b in rd.All("boss"))
if (Str(b, 0).Length > 0) rd.bosses[Str(b, 0)] = b;
foreach (var b in rd.All("btn"))
if (Str(b, 0).Length > 0) rd.btns[Str(b, 0)] = b;
UiText.Use(rd.S_("texts"));
if (!UiText.Has(rd.S_("title_key"))) return null;
return rd;
}
public string S_(string key, string def = "")
{
List<string> l;
return kv.TryGetValue(key, out l) && l.Count > 0 && l[0].Length > 0 ? l[0] : def;
}
string[] L(string key)
{
return S_(key).Split('|');
}
List<string[]> All(string key)
{
var list = new List<string[]>();
List<string> l;
if (kv.TryGetValue(key, out l))
foreach (var v in l)
list.Add(v.Split('|'));
return list;
}
static float F(string v, float def = 0f)
{
float f;
return v != null && float.TryParse(v.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out f) ? f : def;
}
static float At(string[] a, int i, float def = 0f)
{
return a != null && i < a.Length && a[i].Trim().Length > 0 ? F(a[i], def) : def;
}
static string Str(string[] a, int i)
{
return a != null && i < a.Length ? a[i].Trim() : "";
}
static Color Col(string[] a, int i, Color def)
{
Color c;
return a != null && i < a.Length && ColorUtility.TryParseHtmlString(a[i].Trim(), out c) ? c : def;
}
static string N(long v)
{
return v.ToString("N0", CultureInfo.InvariantCulture);
}
static string Pct(float mult)
{
return Mathf.RoundToInt((mult - 1f) * 100f).ToString(CultureInfo.InvariantCulture);
}
/// <summary>제목 띠 부제(메인 점수 보너스 % 넣음).</summary>
public string Subtitle
{
get { return UiText.F(S_("subtitle_key"), new[] { Pct(RaidData.ScoreMult(RaidData.Main)) }); }
}
/// <summary>값 글자(테스트 · 없으면 null).</summary>
public string TextOf(string name)
{
Text t;
return texts.TryGetValue(name, out t) && t != null ? t.text : null;
}
/// <summary>버튼(테스트 · 이름 = Go_main · Go_sub · Detail_main · Practice_sub · Buy_&lt;물품&gt; …).</summary>
public Button ButtonOf(string name)
{
Button b;
return buttons.TryGetValue(name, out b) ? b : null;
}
/// <summary>글자 이름 목록(테스트 · 값 자리 남음 검사).</summary>
public IEnumerable<KeyValuePair<string, Text>> Texts
{
get { return texts; }
}
Sprite Banner(string id)
{
return string.IsNullOrEmpty(id) ? null : Resources.Load<Sprite>(S_("banner") + id);
}
/// <summary>아이콘 지정 = 「res:경로」(Resources) · 그 밖 = 테마 아이콘 id.</summary>
static Sprite IconSprite(string spec)
{
if (string.IsNullOrEmpty(spec)) return null;
return spec.StartsWith("res:", StringComparison.Ordinal) ? Resources.Load<Sprite>(spec.Substring(4)) : UISkin.Icon(spec);
}
static Sprite fadeH;
/// <summary>왼쪽 불투명 → 오른쪽 투명 가로 그라데이션(시안 linear-gradient(90deg) · 색 = Image.color).</summary>
static Sprite FadeH
{
get
{
if (fadeH != null) return fadeH;
const int n = 64;
var tex = new Texture2D(n, 1, TextureFormat.RGBA32, false);
tex.wrapMode = TextureWrapMode.Clamp;
tex.hideFlags = HideFlags.DontSave;
var px = new Color[n];
for (int i = 0; i < n; i++) px[i] = new Color(1f, 1f, 1f, 1f - i / (n - 1f));
tex.SetPixels(px);
tex.Apply();
fadeH = Sprite.Create(tex, new Rect(0, 0, n, 1), new Vector2(0.5f, 0.5f), 100f);
fadeH.hideFlags = HideFlags.DontSave;
return fadeH;
}
}
// ---------- 만들기 ----------
/// <summary>slot(화면 전체 · 제목 띠 뒤)에 처음 한 번 층을 만들고 내용을 다시 채운다 · 배너가 하나도 없으면 false(호출 쪽 = 예전 더미 화면).</summary>
public bool Show(RectTransform slot)
{
if (!Built)
{
bool any = false;
foreach (var b in RaidData.Bosses())
if (Banner(b.id) != null)
{
any = true;
break;
}
if (!any)
{
Debug.LogWarning("[TKS] 맹장 배너 없음: " + S_("banner"));
return false;
}
View = slot;
var body = UiKit.Fill("Body", View, 0f, 0f, OutGameRoot.TopBarH + OutGameRoot.HeaderH, OutGameRoot.TabBarH);
var fit = UiKit.Rect("Fit", body, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(OutGameRoot.Reference.x, OutGameRoot.BodyH));
fit.gameObject.AddComponent<UiFitHeight>().designHeight = OutGameRoot.BodyH; // 본문 높이 맞춤(다른 화면 Body 와 같음)
Design = UiKit.Rect("Design", fit, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(OutGameRoot.Reference.x, OutGameRoot.BodyH));
Art = UiLayer.Group("Art", Design, UiRate.Static);
Info = UiLayer.Group("Info", Design, UiRate.Event, true);
Clock = UiLayer.Group("Clock", Design, UiRate.Frame);
Clock.gameObject.AddComponent<RaidClock>().owner = this;
Built = true;
}
Rebuild();
return true;
}
/// <summary>쪽을 새로 열 때 = 토벌 탭 · 이번 주 메인.</summary>
public void ResetView()
{
Tab = "raid";
Preview = 0;
}
void Rebuild()
{
ContentTables.Reload();
UiKit.Clear(Art);
UiKit.Clear(Info);
UiKit.Clear(Clock);
texts.Clear();
buttons.Clear();
mainClock = subClock = null;
CardCount = TileCount = ShopRows = 0;
var st = L("stroke");
strokeC = Col(st, 0, UiKit.Stroke);
strokeW = At(st, 1, 3f);
var d = S.Save;
var now = S.Now;
Locked = !RaidRules.Unlocked(d);
if (Locked && Tab == "shop") Tab = "raid";
MainId = RaidRules.BossOf(d, RaidData.Main, now);
SubId = RaidRules.BossOf(d, RaidData.Sub, now);
Times(now);
Tabs();
if (Tab == "shop")
{
Shop(d, now);
return;
}
int n = RaidData.Bosses().Count;
Preview = n > 0 ? (Preview % n + n) % n : 0;
ShownMainId = Preview == 0 ? MainId : PreviewBoss(Preview);
var cd = L("card");
float y = At(cd, 1, 114f), step = At(cd, 3, 640f) + At(cd, 4, 14f);
var main = RaidData.Get(ShownMainId);
if (main != null) Card(RaidData.Main, main, y, Preview, n);
var sub = RaidData.Get(SubId);
if (sub != null) Card(RaidData.Sub, sub, y + step, 0, n);
Strip(d);
Tick();
}
// ---------- 일정(교대 시각 · 다음 맹장) — RaidData.Schedule 을 날짜만 바꿔 불러 찾음(새 규칙 없음) ----------
int MainDays
{
get { return Mathf.Max(1, ContentTables.Int(RaidData.Mode, "main_days")); }
}
void Times(DateTime now)
{
mainEnd = subEnd = DateTime.MaxValue;
nextMainName = nextSubName = "";
int week;
string m, s;
RaidData.Schedule(now, out week, out m, out s);
var day0 = now.ToLocalTime().Date;
for (int k = 1; k <= MainDays + 1; k++)
{
var t = day0.AddDays(k); // 현지 자정(Schedule 은 현지 날짜만 봄)
int w2;
string m2, s2;
RaidData.Schedule(t, out w2, out m2, out s2);
if (subEnd == DateTime.MaxValue && (s2 != s || w2 != week))
{
subEnd = t;
nextSubName = NameOf(s2);
}
if (w2 != week)
{
mainEnd = t;
nextMainName = NameOf(m2);
break;
}
}
}
static string NameOf(string id)
{
var b = RaidData.Get(id);
return b != null ? b.nameKo : id ?? "";
}
DateTime PreviewStart(int k)
{
return mainEnd == DateTime.MaxValue ? mainEnd : mainEnd.AddDays((k - 1) * MainDays);
}
string PreviewBoss(int k)
{
var t = PreviewStart(k);
if (t == DateTime.MaxValue) return MainId;
int w;
string m, s;
RaidData.Schedule(t, out w, out m, out s);
return m;
}
string LeftDH(TimeSpan t)
{
if (t < TimeSpan.Zero) t = TimeSpan.Zero;
if (t.Days > 0) return UiText.F("raid_left_dh", new[] { t.Days.ToString(CultureInfo.InvariantCulture), t.Hours.ToString(CultureInfo.InvariantCulture) });
return UiText.F("raid_left_hm", new[] { t.Hours.ToString(CultureInfo.InvariantCulture), t.Minutes.ToString(CultureInfo.InvariantCulture) });
}
static string LeftHMS(TimeSpan t)
{
if (t < TimeSpan.Zero) t = TimeSpan.Zero;
return ((int)t.TotalHours).ToString("00", CultureInfo.InvariantCulture) + ":" + t.Minutes.ToString("00", CultureInfo.InvariantCulture) + ":" + t.Seconds.ToString("00", CultureInfo.InvariantCulture);
}
string MainTime(DateTime nowL)
{
if (Preview > 0) return UiText.F("raid_time_future", new[] { LeftDH(PreviewStart(Preview) - nowL) });
return UiText.F("raid_time_main", new[] { LeftDH(mainEnd - nowL), nextMainName });
}
string SubTime(DateTime nowL)
{
return UiText.F("raid_time_sub", new[] { LeftHMS(subEnd - nowL), nextSubName });
}
/// <summary>교대 남은 시간 다시 씀(RaidClock · 0.5 초마다) · 교대 시각을 넘으면 화면을 다시 그림.</summary>
internal void Tick()
{
if (!Built || Tab != "raid") return;
var nowL = S.Now.ToLocalTime();
if (nowL >= subEnd || nowL >= mainEnd)
{
if (screen.Page == 4 && screen.RaidVisible) screen.Refresh();
return;
}
if (mainClock != null)
{
var s = MainTime(nowL);
if (mainClock.text != s) mainClock.text = s;
}
if (subClock != null)
{
var s = SubTime(nowL);
if (subClock.text != s) subClock.text = s;
}
}
// ---------- 부품 ----------
static readonly Vector2 TopLeft = new Vector2(0f, 1f);
const float RoundRadius = 22f; // UiKit.Round 모서리 반지름(px)
/// <summary>둥근 판(왼쪽 위 기준 · 모서리 반지름 rad = UiKit.Round 9 분할 배율로).</summary>
static Image RoundImg(Transform p, string name, float x, float y, float w, float h, Color c, float rad)
{
var img = UiKit.At(p, name, x, y, w, h).gameObject.AddComponent<Image>();
RoundStyle(img, c, rad);
return img;
}
static void RoundStyle(Image img, Color c, float rad)
{
img.sprite = UiKit.Round;
img.type = Image.Type.Sliced;
img.pixelsPerUnitMultiplier = RoundRadius / Mathf.Max(1f, rad);
img.color = c;
img.raycastTarget = false;
}
/// <summary>테 두른 둥근 판(바깥 = 테 색 · 안 = 바탕) · 반환 = 바깥(크기를 바꾸면 안도 따라감).</summary>
static RectTransform Boxed(Transform p, string name, float x, float y, float w, float h, Color fill, Color border, float bw, float rad, bool raycast)
{
var outer = RoundImg(p, name, x, y, w, h, border, rad);
outer.raycastTarget = raycast;
var inner = UiKit.Fill("Fill", outer.transform, bw, bw, bw, bw).gameObject.AddComponent<Image>();
RoundStyle(inner, fill, rad - bw);
return outer.rectTransform;
}
Text Txt(Transform p, string name, string s, int size, Color c, bool title, bool stroke, TextAnchor a, float x, float y, float w, float h)
{
var t = UiKit.Label(p, s, size, c, a, TopLeft, TopLeft, new Vector2(x, -y), new Vector2(w, h));
if (title) UISkin.UseTitle(t);
if (stroke) UISkin.Stroke(t, strokeC, strokeW);
t.horizontalOverflow = HorizontalWrapMode.Overflow;
t.raycastTarget = false;
t.name = name;
texts[name] = t;
return t;
}
/// <summary>태그(시안 .tag = 테 · 둥근 · 제목 글꼴) · 반환 = 폭.</summary>
float Tag(Transform p, string name, string s, float x, float y, Color bg, Color fg)
{
var tg = L("tag"); // 위|높이|좌우 여백|테|모서리|글자|태그 사이|테 색
return Pill(p, name, s, x, y, At(tg, 1, 42f), At(tg, 2, 14f), At(tg, 3, 4f), At(tg, 4, 12f), (int)At(tg, 5, 26f), bg, fg, Col(tg, 7, Color.black), true);
}
float Pill(Transform p, string name, string s, float x, float y, float h, float pad, float bw, float rad, int fs, Color bg, Color fg, Color border, bool title)
{
var box = Boxed(p, name, x, y, 10f, h, bg, border, bw, rad, false);
var t = Txt(box, name + "Text", s, fs, fg, title, false, TextAnchor.MiddleCenter, 0f, 0f, 10f, h);
float w = Mathf.Ceil(t.preferredWidth) + 2f * (pad + bw);
box.sizeDelta = new Vector2(w, h);
t.rectTransform.sizeDelta = new Vector2(w, h);
return w;
}
/// <summary>버튼(표 btn 줄 = id|폭|스킨|틴트|글자색|외곽선|글자 키) · 오른끝 right 에 붙여 놓고 왼끝 x 를 돌려줌.</summary>
float Btn(Transform p, string name, string id, float right, float y, float h, Action act, bool on)
{
string[] row;
if (!btns.TryGetValue(id, out row)) row = new string[0];
var bt = L("buttons");
float w = At(row, 1, 170f);
float x = right - w;
var b = UiKit.SkinBtn(p, name, Str(row, 2), Col(row, 3, Color.white), "", 10, Color.white, x, y, w, h, act);
var bl = b.GetComponentInChildren<Text>();
if (bl != null) bl.gameObject.SetActive(false);
Txt(b.transform, name + "Text", UiText.T(Str(row, 6)), (int)At(bt, 4, 32f), Col(row, 4, Color.white), true, At(row, 5) > 0f, TextAnchor.MiddleCenter, 0f, -At(bt, 5, 4f), w, h);
b.interactable = on;
buttons[name] = b;
return x;
}
// ---------- 탭 ----------
void Tabs()
{
var tb = L("tabs"); // 왼|위|폭|높이|사이|테|모서리|글자|테 색|꺼짐|켜짐|글자색
var tabs = All("tab");
int n = tabs.Count;
if (n == 0) return;
float x0 = At(tb, 0, 24f), y = At(tb, 1, 22f), w = At(tb, 2, 1032f), h = At(tb, 3, 78f), gap = At(tb, 4, 18f);
float tw = (w - gap * (n - 1)) / n;
for (int i = 0; i < n; i++)
{
string act = Str(tabs[i], 0);
bool on = act == Tab;
var box = Boxed(Info, "Tab_" + act, x0 + i * (tw + gap), y, tw, h, Col(tb, on ? 10 : 9, UiKit.Dark), Col(tb, 8, Color.black), At(tb, 5, 5f), At(tb, 6, 18f), true);
Txt(box, "TabText_" + act, UiText.T(Str(tabs[i], 1)), (int)At(tb, 7, 34f), Col(tb, 11, Color.white), true, false, TextAnchor.MiddleCenter, 0f, 0f, tw, h);
var b = box.gameObject.AddComponent<Button>();
b.targetGraphic = box.GetComponent<Image>();
b.transition = Selectable.Transition.None;
b.onClick.AddListener(() => PressTab(act));
buttons["Tab_" + act] = b;
}
}
/// <summary>탭 누름: raid = 토벌 카드 · rank = 순위 표(서버 모드 · 기기 세이브 = 알림) · shop = 훈장 상점(해금 전 = 알림).</summary>
public void PressTab(string act)
{
switch (act)
{
case "rank":
if (S.RankAvailable) Net.RankPanel.Open(screen.Root, ArenaRules.Raid);
else screen.Root.Toast(UiText.T("raid_rank_offline"));
return;
case "shop":
if (Locked)
{
screen.Root.Toast(UnlockText());
return;
}
break;
case "raid":
break;
default:
Debug.LogWarning("[TKS] 맹장 토벌전 탭 연결 없음: " + act);
return;
}
if (Tab == act) return;
Tab = act;
Rebuild();
}
string UnlockText()
{
return UiText.F("raid_unlock", new[] { ContentTables.Str(RaidData.Mode, "unlock_stage") });
}
// ---------- 넘김(메인 맹장 미리 보기) ----------
public void NextBoss()
{
Preview++;
Rebuild();
}
public void PrevBoss()
{
Preview--;
Rebuild();
}
// ---------- 카드 ----------
void Card(string slot, RaidData.Boss b, float top, int preview, int bossCount)
{
bool isMain = slot == RaidData.Main;
var cd = L("card"); // 왼|첫 카드 위|폭|높이|카드 사이|테|모서리|테 색|바탕
float x = At(cd, 0, 24f), w = At(cd, 2, 1032f), h = At(cd, 3, 640f), bw = At(cd, 5, 8f), rad = At(cd, 6, 30f);
float iw = w - 2f * bw, ih = h - 2f * bw;
// 그림(Static): 테 → 안쪽(둥근 마스크) → 배너 → 왼쪽 어둡게
var frame = RoundImg(Art, "Card_" + slot, x, top, w, h, Col(cd, 7, Color.black), rad);
var inner = RoundImg(frame.transform, "Inner", bw, bw, iw, ih, Col(cd, 8, UiKit.Dark), rad - bw);
inner.gameObject.AddComponent<Mask>().showMaskGraphic = true;
var sp = Banner(b.id);
if (sp != null)
{
var bi = UiKit.At(inner.transform, "Banner_" + b.id, 0f, 0f, iw, ih).gameObject.AddComponent<Image>();
bi.sprite = sp;
bi.raycastTarget = false; // 해금 전도 평소 그림(어둡게 = 화면 위 잠김 덮개 LockOverlay)
}
var sh = L("shade");
var si = UiKit.At(inner.transform, "Shade", 0f, 0f, At(sh, 0, 560f), ih).gameObject.AddComponent<Image>();
si.sprite = FadeH;
si.color = Col(sh, 1, new Color(0.08f, 0.04f, 0.08f, 0.72f));
si.raycastTarget = false;
// 값(Event) — 카드 안쪽 왼쪽 위 기준 · 카드 누름 = 상세 정보
var box = UiKit.At(Info, "CardInfo_" + slot, x + bw, top + bw, iw, ih);
var press = box.gameObject.AddComponent<Image>();
press.color = new Color(1f, 1f, 1f, 0f);
press.canvasRenderer.cullTransparentMesh = true; // 누름만 · 그리지 않음
press.raycastTarget = true;
var pb = box.gameObject.AddComponent<Button>();
pb.transition = Selectable.Transition.None;
string detailSlot = preview == 0 ? slot : null;
pb.onClick.AddListener(() => Detail(b, detailSlot));
var clk = UiKit.At(Clock, "CardClock_" + slot, x + bw, top + bw, iw, ih);
float ix = F(S_("info_x"), 70f);
var tg = L("tag");
float tx = ix, ty = At(tg, 0, 30f);
if (isMain)
{
var tc = L(preview == 0 ? "tag_main" : "tag_future");
tx += Tag(box, "Tag_" + slot, UiText.F(preview == 0 ? "raid_tag_main" : "raid_tag_future", new[] { preview.ToString(CultureInfo.InvariantCulture) }), tx, ty, Col(tc, 0, UiKit.Purple), Col(tc, 1, Color.white)) + At(tg, 6, 10f);
float mult = RaidData.ScoreMult(slot);
if (mult > 1.0001f)
{
var bc = L("tag_bonus");
Tag(box, "Bonus_" + slot, UiText.F("raid_tag_bonus", new[] { Pct(mult) }), tx, ty, Col(bc, 0, UiKit.Coin), Col(bc, 1, UiKit.Ink));
}
}
else
{
var tc = L("tag_sub");
Tag(box, "Tag_" + slot, UiText.T("raid_tag_sub"), tx, ty, Col(tc, 0, UiKit.Dark), Col(tc, 1, Color.white));
}
// 이름 · 칭호 · 군령
var nm = L("name"); // 위|글자|줄 높이|이름 색
string name = "<color=" + Str(nm, 3) + ">" + b.nameKo + "</color>";
Txt(box, "Name_" + slot, UiText.F("raid_name", new[] { name }), (int)At(nm, 1, 84f), Color.white, true, true, TextAnchor.MiddleLeft, ix, At(nm, 0, 78f), iw - ix, At(nm, 2, 105f));
var ti = L("title");
Txt(box, "Title_" + slot, b.titleKo, (int)At(ti, 1, 32f), Col(ti, 3, UiKit.Coin), true, false, TextAnchor.MiddleLeft, ix, At(ti, 0, 183f), iw - ix, At(ti, 2, 40f));
var od = L("order"); // 위|칩 높이|칩 글자|군령 글자|칩 뒤 간격|칩 모서리|칩 테|칩 색|칩 글자색
float oy = At(od, 0, 235f), oh = At(od, 1, 38f);
float cw = Pill(box, "OrderChip_" + slot, UiText.T("raid_order_chip"), ix, oy, oh, At(tg, 2, 14f), At(od, 6, 4f), At(od, 5, 8f), (int)At(od, 2, 23f), Col(od, 7, UiKit.Coin), Col(od, 8, UiKit.Ink), Col(tg, 7, Color.black), true);
Txt(box, "Order_" + slot, b.orderBuffKo, (int)At(od, 3, 30f), Color.white, true, true, TextAnchor.MiddleLeft, ix + cw + At(od, 4, 10f), oy, iw, oh);
// 교대(Clock 층 · 1초마다)
var tm = L("time"); // 위|글자|줄 높이|색
var clock = Txt(clk, "Time_" + slot, "", (int)At(tm, 1, 27f), Col(tm, 3, Color.white), true, true, TextAnchor.MiddleLeft, ix, At(tm, 0, 283f), iw - ix, At(tm, 2, 34f));
if (isMain) mainClock = clock;
else subClock = clock;
if (isMain)
{
Tiles(box, b, ix);
if (preview == 0) Record(box, ix);
if (bossCount > 1) Arrows(box, iw);
}
else
{
var sn = L("sub_note"); // 위|글자|줄 높이|색
float mult = RaidData.ScoreMult(slot);
string note = mult > 1.0001f ? UiText.F("raid_sub_bonus", new[] { Pct(mult) }) : UiText.T("raid_sub_no_bonus");
Txt(box, "Note_" + slot, note, (int)At(sn, 1, 25f), Col(sn, 3, UiKit.InkSoft), true, true, TextAnchor.MiddleLeft, ix, At(sn, 0, 323f), iw - ix, At(sn, 2, 31f));
}
CardButtons(box, slot, b, preview, iw, ih);
CardCount++;
}
/// <summary>맹장 · 패턴 · 약점 칸 3(시안 tile · 열 폭 = max(칸 · 이름 폭)).</summary>
void Tiles(RectTransform box, RaidData.Boss b, float ix)
{
var tl = L("tiles"); // 위|칸|모서리|테|칸 사이|이름 글자|이름 틈|이름 줄|테 색|이름 색
float top = At(tl, 0, 331f), sz = At(tl, 1, 90f), rad = At(tl, 2, 18f), bw = At(tl, 3, 5f), gap = At(tl, 4, 16f);
float lgap = At(tl, 6, 4f), lline = At(tl, 7, 26f);
int lfs = (int)At(tl, 5, 21f);
string[] row;
bosses.TryGetValue(b.id, out row);
var tb = L("tile_boss");
var tp = L("tile_pattern");
var tw = L("tile_weak");
var items = new[]
{
new KeyValuePair<string, object[]>("boss", new object[] { Col(tb, 0, UiKit.Dark), UiKit.ArtSprite(b.art), At(tb, 1, 140f), UiText.T("raid_tile_boss") }),
new KeyValuePair<string, object[]>("pattern", new object[] { Col(tp, 0, UiKit.Red), IconSprite(Str(row, 1)), At(tp, 1, 70f), UiText.T("raid_pat_" + b.id) }),
new KeyValuePair<string, object[]>("weak", new object[] { Col(tw, 0, UiKit.Jade), IconSprite(Str(row, 2)), At(row, 3, At(tw, 1, 70f)), UiText.T("raid_weak_" + b.id) }),
};
float cx = ix;
foreach (var it in items)
{
var v = it.Value;
var lab = Txt(box, "TileText_" + it.Key, (string)v[3], lfs, Col(tl, 9, Color.white), false, false, TextAnchor.MiddleCenter, cx, top + sz + lgap, 10f, lline);
float colW = Mathf.Max(sz, Mathf.Ceil(lab.preferredWidth));
lab.rectTransform.sizeDelta = new Vector2(colW, lline);
var cell = Boxed(box, "Tile_" + it.Key, cx + (colW - sz) * 0.5f, top, sz, sz, (Color)v[0], Col(tl, 8, Color.black), bw, rad, false);
var fill = cell.Find("Fill");
fill.gameObject.AddComponent<Mask>().showMaskGraphic = true;
var sp = v[1] as Sprite;
if (sp != null)
{
float imgW = (float)v[2];
var r = sp.rect;
var img = UiKit.Rect("Img", fill, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(imgW, imgW * r.height / Mathf.Max(1f, r.width))).gameObject.AddComponent<Image>();
img.sprite = sp;
img.raycastTarget = false;
}
cx += colW + gap;
TileCount++;
}
}
/// <summary>오늘 기록 칩(시안 .chip) — 게임 세이브에 하루 기록이 없어 표 example_record · 점수 = 기록 × 메인 배율.</summary>
void Record(RectTransform box, float ix)
{
var rc = L("record"); // 위|높이|테|모서리|글자|좌우 여백|테 색|바탕
long rec = (long)F(S_("example_record"));
long score = (long)Math.Floor(rec * RaidData.ScoreMult(RaidData.Main) + 1e-6);
Pill(box, "Record", UiText.F("raid_record", new[] { N(rec), N(score) }), ix, At(rc, 0, 463f), At(rc, 1, 50f), At(rc, 5, 18f), At(rc, 2, 4f), At(rc, 3, 25f), (int)At(rc, 4, 26f), Col(rc, 7, UiKit.Dark), Color.white, Col(rc, 6, Color.black), false);
}
void Arrows(RectTransform box, float iw)
{
var ar = L("arrows"); // 가장자리|위|지름|바탕|왼 아이콘|오른 아이콘|아이콘 크기|왼 회전|오른 회전|왼 x 밀기|오른 x 밀기
float edge = At(ar, 0, 10f), y = At(ar, 1, 286f), dd = At(ar, 2, 56f), isz = At(ar, 6, 30f);
for (int s = 0; s < 2; s++)
{
bool left = s == 0;
var rt = UiKit.At(box, left ? "Prev" : "Next", left ? edge : iw - edge - dd, y, dd, dd);
var img = rt.gameObject.AddComponent<Image>();
img.sprite = UiKit.Circle;
img.color = Col(ar, 3, new Color(0.08f, 0.09f, 0.16f, 0.8f));
img.raycastTarget = true;
// 채운 삼각형(시안 ◀ ▶) = 테마 아이콘을 표의 각도만큼 돌림(팩 아래 삼각형 arrow_down · QA M 2026-11-18)
var ic = UISkin.IconImage(rt, Str(ar, left ? 4 : 5), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(At(ar, left ? 9 : 10, 0f), 0f), new Vector2(isz, isz));
if (ic != null) ic.rectTransform.localEulerAngles = new Vector3(0f, 0f, At(ar, left ? 7 : 8, 0f));
else Txt(rt, left ? "PrevText" : "NextText", left ? "◀" : "▶", (int)isz, Color.white, true, false, TextAnchor.MiddleCenter, 0f, 0f, dd, dd);
var b = rt.gameObject.AddComponent<Button>();
b.targetGraphic = img;
if (left) b.onClick.AddListener(PrevBoss);
else b.onClick.AddListener(NextBoss);
buttons[left ? "Prev" : "Next"] = b;
}
}
/// <summary>카드 버튼 줄(오른쪽 아래 · 표 main_buttons / sub_buttons) — go = 오늘 도전 가능 · 다 씀(도전함) · 못 함(누르면 이유) · 잠김 · 미리 보기 = 상세 정보만.</summary>
void CardButtons(RectTransform box, string slot, RaidData.Boss b, int preview, float iw, float ih)
{
var bt = L("buttons"); // 오른 여백|아래 여백|높이|사이|글자|글자 위로
float h = At(bt, 2, 76f), y = ih - At(bt, 1, 20f) - h, gap = At(bt, 3, 12f);
var ids = preview > 0 ? new[] { "detail" } : L(slot == RaidData.Main ? "main_buttons" : "sub_buttons");
var d = S.Save;
var now = S.Now;
float right = iw - At(bt, 0, 22f);
for (int i = ids.Length - 1; i >= 0; i--)
{
string id = ids[i].Trim();
switch (id)
{
case "detail":
right = Btn(box, "Detail_" + slot, "detail", right, y, h, () => Detail(b, preview == 0 ? slot : null), true);
break;
case "practice":
right = Btn(box, "Practice_" + slot, "practice", right, y, h, () => screen.RaidGo(slot, true), true);
break;
case "go":
{
string why = RaidRules.Can(d, slot, false, now);
int used = RaidRules.Used(d, slot, now), limit = RaidData.EntryLimit(slot);
if (Locked) right = Btn(box, "Go_" + slot, "locked", right, y, h, null, false);
else if (why == null) right = Btn(box, "Go_" + slot, "go", right, y, h, () => screen.RaidGo(slot, false), true);
else if (limit > 0 && used >= limit) right = Btn(box, "Go_" + slot, "done", right, y, h, null, false);
else right = Btn(box, "Go_" + slot, "go_off", right, y, h, () => screen.Root.Toast(why), true);
break;
}
default:
continue;
}
right -= gap;
}
}
/// <summary>상세 정보 창 = 군령 · 패턴 · 빈틈(게임 표 raid_rotation) · 이번 맹장이면 연습 버튼(메인 연습 = 여기).</summary>
public void Detail(RaidData.Boss b, string slot)
{
if (b == null) return;
LastDetail = b.id;
var body = string.Join("\n\n", new[]
{
UiText.F("raid_detail_order", new[] { b.orderBuffKo }),
UiText.F("raid_detail_pattern", new[] { b.patternKo }),
UiText.F("raid_detail_weak", new[] { b.weakKo }),
});
var list = new List<OutGameRoot.ModalButton>();
if (slot != null && !Locked) list.Add(new OutGameRoot.ModalButton(UiText.T("raid_practice"), UiKit.Red, () => screen.RaidGo(slot, true)));
list.Add(new OutGameRoot.ModalButton(UiText.T("raid_close"), UiKit.Dark, null));
screen.Root.Modal(UiText.F("raid_detail_title", new[] { b.nameKo }), body, list.ToArray());
}
// ---------- 주간 점수 띠 ----------
void Strip(SaveData d)
{
var sp = L("strip"); // 왼|위|폭|높이|테|모서리|안쪽 여백|테 색|바탕
float x = At(sp, 0, 24f), y = At(sp, 1, 1420f), w = At(sp, 2, 1032f), h = At(sp, 3, 104f), bw = At(sp, 4, 5f), rad = At(sp, 5, 26f), pad = At(sp, 6, 22f);
Boxed(Art, "Strip", x, y, w, h, Col(sp, 8, UiKit.Dark), Col(sp, 7, Color.black), bw, rad, false);
var box = UiKit.At(Info, "StripInfo", x, y, w, h);
if (S.RankAvailable) // 서버 모드 = 띠를 누르면 순위 표
{
var pi = box.gameObject.AddComponent<Image>();
pi.color = new Color(1f, 1f, 1f, 0f);
pi.canvasRenderer.cullTransparentMesh = true;
pi.raycastTarget = true;
var pb = box.gameObject.AddComponent<Button>();
pb.transition = Selectable.Transition.None;
pb.onClick.AddListener(() => Net.RankPanel.Open(screen.Root, ArenaRules.Raid));
}
var rs = d.raid;
var sl = L("strip_left"); // 위|이름 글자|이름 줄|이름 색|점수 글자|점수 줄|점수 색
float ly = At(sl, 0, 14f), ll = At(sl, 2, 26f);
Txt(box, "ScoreLabel", UiText.T("raid_score_label"), (int)At(sl, 1, 21f), Col(sl, 3, UiKit.InkSoft), false, false, TextAnchor.MiddleLeft, pad, ly, w * 0.5f, ll);
Txt(box, "Score", N(rs.score), (int)At(sl, 4, 40f), Col(sl, 6, UiKit.Coin), true, false, TextAnchor.MiddleLeft, pad, ly + ll, w * 0.5f, At(sl, 5, 50f));
// 누적 단계 상자(오른쪽 끝) · 누르면 단계 창
var ch = L("strip_chest"); // 칸|모서리|테|테 색|바탕|아이콘|아이콘 id
float cs = At(ch, 0, 76f);
float cx = w - pad - cs;
var cb = Boxed(box, "Chest", cx, (h - cs) * 0.5f, cs, cs, Col(ch, 4, UiKit.Dark), Col(ch, 3, Color.black), At(ch, 2, 4f), At(ch, 1, 18f), true);
UISkin.IconImage(cb, Str(ch, 6), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(At(ch, 5, 54f), At(ch, 5, 54f)));
var chb = cb.gameObject.AddComponent<Button>();
chb.targetGraphic = cb.GetComponent<Image>();
chb.onClick.AddListener(Steps);
buttons["Chest"] = chb;
// 순위 · 상위 % · 내역(오른쪽 맞춤)
var sr = L("strip_right"); // 상자 앞 간격|순위 가운데 y|순위 글자|상위 % 글자|상위 % 색|내역 가운데 y|내역 글자|내역 색
float rx = cx - At(sr, 0, 16f);
string rank, top;
if (rs.serverView && rs.rank > 0)
{
rank = N(rs.rank);
top = N(Mathf.Max(1, Mathf.CeilToInt(rs.rank * 100f / Mathf.Max(1, rs.rankTotal))));
}
else
{
var ex = L("example_rank"); // 서버 순위가 없음 = 시안 예시 값
rank = Str(ex, 0);
top = Str(ex, 1);
}
int rfs = (int)At(sr, 2, 34f);
string line = UiText.F("raid_rank", new[] { rank }) + " <size=" + (int)At(sr, 3, 24f) + "><color=" + Str(sr, 4) + ">" + UiText.F("raid_top", new[] { top }) + "</color></size>";
float rl = rfs * 1.3f;
Txt(box, "Rank", line, rfs, Color.white, true, false, TextAnchor.MiddleRight, rx - w * 0.6f, At(sr, 1, 37f) - rl * 0.5f, w * 0.6f, rl);
int dfs = (int)At(sr, 6, 20f);
float dl = dfs * 1.4f;
string mult = RaidData.ScoreMult(RaidData.Main).ToString("0.##", CultureInfo.InvariantCulture);
Txt(box, "Breakdown", UiText.F("raid_breakdown", new[] { N(rs.mainDamage), mult, N(rs.subDamage) }), dfs, Col(sr, 7, UiKit.InkSoft), false, false, TextAnchor.MiddleRight, rx - w * 0.6f, At(sr, 5, 73f) - dl * 0.5f, w * 0.6f, dl);
}
/// <summary>누적 피해 단계 창(게임 표 raid_rewards milestone · 받은 단계 = 세이브 milestones).</summary>
public void Steps()
{
var d = S.Save;
var db = S.Db;
var lines = new List<string> { UiText.F("raid_steps_score", new[] { N(d.raid.score) }) };
foreach (var r in ContentTables.Rows(RaidData.Rewards))
{
if (r.S("e_kind") != "milestone") continue;
bool got = d.raid.milestones.Contains(r.I("n_step"));
lines.Add(UiText.F(got ? "raid_step_on" : "raid_step_off", new[] { r.S("s_band_ko"), N(r.I("n_score_min")), Prize(r, db) }));
}
screen.Root.Modal(UiText.T("raid_steps_title"), string.Join("\n", lines.ToArray()), new OutGameRoot.ModalButton(UiText.T("raid_close"), UiKit.Dark, null));
}
static string Prize(ContentRow r, OutGameData db)
{
var got = new List<string>();
int gem = r.I("n_gem"), coin = r.I("n_raid_coin");
if (gem > 0) got.Add(UiText.F("raid_rw_gem", new[] { N(gem) }));
if (coin > 0) got.Add(UiText.F("raid_rw_coin", new[] { N(coin) }));
foreach (var kvp in ContentTables.ParseMap(r.S("s_chest")))
{
var c = db.Chests.Get(kvp.Key);
got.Add(UiText.F("raid_rw_chest", new[] { c != null ? c.nameKo : kvp.Key, N(Mathf.RoundToInt(kvp.Value)) }));
}
return string.Join(" · ", got.ToArray());
}
// ---------- 훈장 상점 탭(시안 없음 · 점수 띠와 같은 판) ----------
void Shop(SaveData d, DateTime now)
{
var rows = ContentTables.Rows(RaidData.Shop);
var sh = L("shop"); // 위|머리 높이|줄 높이|아이템 칸|이름 글자|작은 글자|안쪽 여백|줄 사이
var sp = L("strip");
var sr = L("shop_row"); // 바탕|모서리|구매 버튼 폭|높이
var ci = L("coin_icon"); // 아이콘|머리 크기|가격 크기
float x = At(sp, 0, 24f), w = At(sp, 2, 1032f), top = At(sh, 0, 114f), headH = At(sh, 1, 96f), rowH = At(sh, 2, 176f), tile = At(sh, 3, 116f), pad = At(sh, 6, 16f), rg = At(sh, 7, 12f);
int nfs = (int)At(sh, 4, 30f), sfs = (int)At(sh, 5, 22f);
float H = headH + rows.Count * rowH + pad;
Boxed(Art, "ShopPanel", x, top, w, H, Col(sp, 8, UiKit.Dark), Col(sp, 7, Color.black), At(sp, 4, 5f), At(sp, 5, 26f), false);
var box = UiKit.At(Info, "Shop", x, top, w, H);
float hs = At(ci, 1, 56f);
UISkin.IconImage(box, Str(ci, 0), TopLeft, new Vector2(0f, 0.5f), new Vector2(pad + 12f, -headH * 0.5f), new Vector2(hs, hs));
Txt(box, "Coins", UiText.F("raid_shop_coins", new[] { N(d.raid.coins) }), nfs + 2, Color.white, true, true, TextAnchor.MiddleLeft, pad + 24f + hs, 0f, w * 0.7f, headH);
float bw = At(sr, 2, 200f), bh = At(sr, 3, 80f);
var shopIcons = new Dictionary<string, string>();
foreach (var p in L("shop_icons"))
{
var kvp = p.Split(':');
if (kvp.Length == 2) shopIcons[kvp[0].Trim()] = kvp[1].Trim();
}
for (int i = 0; i < rows.Count; i++)
{
var r = rows[i];
string item = r.S("s_item"), pick = r.S("e_pick");
int bought = RaidRules.Bought(d, item, now), limit = r.I("n_weekly_limit");
float ry = headH + i * rowH, rh = rowH - rg;
RoundImg(Art, "ShopRow_" + item, x + pad, top + ry, w - 2f * pad, rh, Col(sr, 0, UiKit.Dark), At(sr, 1, 20f));
string ic;
shopIcons.TryGetValue(item, out ic);
UiKit.RewardTile(box, "Item_" + item, pad + 20f, ry + (rh - tile) * 0.5f, tile, "gear_white_", ic ?? "", "×" + r.I("n_amount").ToString(CultureInfo.InvariantCulture), false);
float tx = pad + 20f + tile + 28f;
Txt(box, "ItemName_" + item, r.S("s_name_ko"), nfs, Color.white, true, true, TextAnchor.MiddleLeft, tx, ry + rh * 0.5f - nfs * 1.3f, w * 0.45f, nfs * 1.3f);
Txt(box, "ItemLimit_" + item, UiText.F("raid_shop_limit", new[] { N(bought), N(limit) }), sfs, Col(L("strip_right"), 7, UiKit.InkSoft), false, false, TextAnchor.MiddleLeft, tx, ry + rh * 0.5f + 4f, w * 0.45f, sfs * 1.4f);
// 가격(훈장 아이콘 + 수) · 구매(기존 처리 RaidBuyPick)
float right = w - pad - 20f;
bool can = bought < limit;
string pk = pick;
float bx = Btn(box, "Buy_" + item, can ? "buy" : "soldout", right, ry + (rh - bh) * 0.5f, bh, () => screen.RaidBuyPick(item, pk), can);
float ps = At(ci, 2, 40f);
var price = Txt(box, "ItemPrice_" + item, N(r.I("n_price")), nfs, UiKit.Col("coin", UiKit.Coin), true, true, TextAnchor.MiddleRight, bx - 24f - 200f, ry + (rh - nfs * 1.3f) * 0.5f, 200f, nfs * 1.3f);
UISkin.IconImage(box, Str(ci, 0), TopLeft, new Vector2(1f, 0.5f), new Vector2(bx - 24f - Mathf.Ceil(price.preferredWidth) - 8f, -(ry + rh * 0.5f)), new Vector2(ps, ps));
ShopRows++;
}
}
}
/// <summary>맹장 토벌전 교대 남은 시간(1초 단위 글자 · Clock 층 = Frame) — 0.5 초마다 ArenaRaid.Tick.</summary>
public class RaidClock : MonoBehaviour
{
public ArenaRaid owner;
float next;
void Update()
{
if (owner == null || Time.unscaledTime < next) return;
next = Time.unscaledTime + 0.5f;
owner.Tick();
}
}
}