ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Mission/MissionScreen.cs

626 lines
33 KiB
C#
Raw Normal View History

성장 · 임무 · 출정 · 외형 · 정보 일괄 — 임무(미션) 메뉴 · 영웅 각성 · 진화(진영 비서) · 스킬 강화(영웅 조각 + 만능 조각) · 각성 칸 = 승급 장비 등급 · 장비 등급 7(불멸 red · 신화 rainbow) · 병종 장비 210 · 장별 드랍 · 영웅 Lv100 · 출정 = 로비 편성(학습 판 = 연의 전기만) · 보스 말풍선만 · 1장 레벨디자인 · 외형(코스튬) 꾸미기 레이어 · 영웅 정보(능력치 · 열전) - 임무: 일일 · 주간 · 업적 · 카운터 36 · 우편 · 로비 버튼(MissionTests) - 각성 · 진화: 표 11장 · 진화 = ★ 최대 레벨 + 진영 비서 + 골드 · 비서 교환 · 각성 굴림 · 잠금 · 칸 = 승급 장비 등급(AwakenTests) - 스킬 강화: skill_upgrade · skill_config(최고 Lv10 · 상한 = 영웅 레벨 10 단위) · 만능 조각 확인 팝업 - 장비: gear_grades · gear_kinds · gear_drop_chapters · gear_drop_stages · 승급 7단계 · 무지개 7색 순환(UiRainbow) · TKS/Import Gear(GearTests) - 출정: 학습 판 = 연의 전기 서장만(WantsTutorialPlan) · boss_intro_config talk_main · 1장 표 · 1-4 가시덤불 정정(MainStageTests · TutorialTests [Ignore]) - 외형: 부위 4(외형 = 추후) · 꾸미기 9 · 기준점 · 알파 경계 · 전투 · UI 레이어 · 미리보기 · 상세(CostumeTests) - 정보: 능력치(기본 + 성장 = 합계 · HeroRules 그대로) · 전투 능력치 7 · 성장 내역 · 내역 창 · 열전(HeroInfoTests) - 같은 작업 트리의 다른 세션 미커밋 변경(스킬 이펙트 · 전투 해석기 · 보급전 표 · 스킬 표 등)은 넣지 않음 PD 2026-11-20 「지금까지 본 PC에서 구현된 모든 성장 관련 기능을 다른 세션에서 확인할 수 있도록 푸시까지 진행해」 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 03:15:36 +00:00
using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 임무 화면(2026-11-20 PD 컨펌 · 목업 미션_img 02~06) — 탭 3(일일 · 주간 · 업적 · 빨간 점 = 받기 줄 수) · 포인트 판(원 + 막대 + 구간 상자 + 초기화 시계) ·
/// 임무 줄(아이콘 · 제목 · 대체 표시 · 진행 막대 · 도움말 · +포인트 · 받기/완료/이동/진행 중) · 업적(분류 칩 · 지금 단계 1줄 · 연쇄 안내) · 모두 받기 · 보상 팝업.
/// 값 = 임무 표(MissionDb) · 글자 = UI/Mission/mission_text · 아이콘·색·바로가기 = UI/Mission/mission_screen(C45).
/// 캔버스 = 화면 Event(OutGameRoot.Add) · 줄 목록 = ScrollGrid Frame · 시계 칩 = 자기 Event 캔버스(1초마다 글자만).
/// </summary>
public class MissionScreen : OutGameScreen
{
public const string Table = "UI/Mission/mission_screen";
public const string Texts = "UI/Mission/mission_text";
public const int DailyTab = 0, WeeklyTab = 1, AchieveTab = 2;
const float RowW = 1032f;
const float RowH = 100f;
const float AchH = 132f;
const float BottomH = 136f;
static Dictionary<string, string> cfg;
int tab;
string cat = "";
RectTransform body;
RectTransform page;
readonly Button[] tabs = new Button[3];
readonly Text[] tabBadges = new Text[3];
/// <summary>시험 · 캡처용 — 지금 탭 · 줄 상태(claim · done · go · wait) · 마지막 팝업 제목.</summary>
public int CurrentTab
{
get { return tab; }
}
public readonly List<string> RowStates = new List<string>();
public readonly List<string> RowTitles = new List<string>();
public string LastPopup { get; private set; }
public static string T(string key)
{
return UiText.T(key).Replace("\\n", "\n");
}
public static string F(string key, params string[] args)
{
return UiText.F(key, args).Replace("\\n", "\n");
}
/// <summary>화면 표 값(없으면 def).</summary>
public 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;
}
public static Color Col(string key, Color def)
{
Color c;
return ColorUtility.TryParseHtmlString(Cfg("color." + key), out c) ? c : def;
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetStatics()
{
cfg = null;
}
public override void Build()
{
UiText.Use(Texts);
Header(T("mission_title"), T("mission_sub"), true);
body = Body();
string[] keys = { "tab_daily", "tab_weekly", "tab_achieve" };
for (int i = 0; i < 3; i++)
{
int k = i;
tabs[i] = UiKit.SubTab(body, "Tab" + i, T(keys[i]), 24f + i * 348f, 18f, 332f, 84f, () => SetTab(k));
var b = UiKit.Skin(UiKit.Rect("Badge", tabs[i].transform, new Vector2(1f, 1f), new Vector2(0.5f, 0.5f), new Vector2(-10f, -6f), new Vector2(48f, 50f)), "badge_circle", Col("badge", UiKit.Red));
b.preserveAspect = true;
tabBadges[i] = UiKit.Title(UiKit.FillLabel(b.transform, "", 26, UiKit.White), true);
}
page = UiKit.Fill("Page", body, 0f, 0f, 116f, 0f);
}
public override void OnShow()
{
S.MissionRoll();
}
public void SetTab(int t)
{
tab = Mathf.Clamp(t, 0, 2);
Refresh();
}
public void SetCategory(string c)
{
cat = c ?? "";
Refresh();
}
public override void Refresh()
{
if (page == null || S.Db.Missions == null) return;
var og = S.Db;
var d = S.Save;
int[] n = { MissionRules.Badge(og, d, MissionDb.Daily), MissionRules.Badge(og, d, MissionDb.Weekly), MissionRules.AchBadge(og, d) };
for (int i = 0; i < 3; i++)
{
UiKit.SetSubTab(tabs[i], i == tab);
tabBadges[i].text = n[i].ToString(CultureInfo.InvariantCulture);
tabBadges[i].transform.parent.gameObject.SetActive(n[i] > 0);
}
UiKit.Clear(page);
RowStates.Clear();
RowTitles.Clear();
if (tab == AchieveTab) BuildAchievements();
else BuildMissions(tab == DailyTab ? MissionDb.Daily : MissionDb.Weekly);
}
// ---------- 일일 · 주간 ----------
void BuildMissions(string kind)
{
var og = S.Db;
var db = og.Missions;
var d = S.Save;
int max = db.PointMax(kind);
int pts = MissionRules.Points(d, kind);
var panel = UiKit.At(page, "Points", 24f, 4f, RowW, 262f);
UiKit.Skin(panel, "card", Col("panel", UiKit.Dark));
Txt(panel, "Title", T("points_" + kind), 34, Col("text", UiKit.White), 30f, 16f, 360f, 50f, TextAnchor.MiddleLeft, true);
Timer(panel, kind);
// 원(지금 포인트 / 상한)
foreach (var ring in new[] { UiKit.Box("Ring", panel, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(105f, -160f), new Vector2(152f, 152f), Col("ring", UiKit.Coin)),
UiKit.Box("Inner", panel, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(105f, -160f), new Vector2(138f, 138f), Col("chip", UiKit.Dark)) })
{
ring.sprite = UiKit.Circle; // 평면 원(팩 dot 은 검은 외곽선이 있어 금테가 안 보임)
ring.type = Image.Type.Simple;
}
var pv = UiKit.Title(UiKit.Label(panel, pts.ToString(CultureInfo.InvariantCulture), 62, Col("text_gold", UiKit.Coin), TextAnchor.MiddleCenter, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(105f, -146f), new Vector2(140f, 70f)), true);
pv.name = "PointValue";
UiKit.Label(panel, F("point_max", max.ToString(CultureInfo.InvariantCulture)), 24, Col("text_dim", UiKit.InkSoft), TextAnchor.MiddleCenter, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(105f, -196f), new Vector2(140f, 34f));
// 막대 + 구간 상자
const float X0 = 216f, W = 760f, BarY = 150f;
var fill = UiKit.Bar("Bar", panel, new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(X0, -BarY), new Vector2(W, 30f), Col("chip", UiKit.Dark), Col("bar_full", UiKit.Coin));
UiKit.SetBar(fill, max > 0 ? pts / (float)max : 0f);
var steps = db.Steps(kind);
var icons = Split(Cfg("box_icons"));
for (int i = 0; i < steps.Count; i++)
{
var s = steps[i];
float x = X0 + W * Mathf.Clamp01(s.need / (float)Mathf.Max(1, max));
bool got = MissionRules.BoxClaimed(d, kind, s.step);
bool ready = !got && pts >= s.need;
string icon = icons.Count == 0 ? "" : icons[Mathf.Min(icons.Count - 1, Mathf.RoundToInt(i * (icons.Count - 1) / (float)Mathf.Max(1, steps.Count - 1)))];
var box = UiKit.Rect("Box" + s.step, panel, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(x, -BarY + 4f), new Vector2(96f, 96f));
UiKit.Skin(box, "card", Col("chip", UiKit.Dark), true);
if (ready)
{
// 빛남 = 뒤 판만 깜빡임(UiPulse = 자기 Frame 캔버스 · 누름은 상자 판이 받음)
var glow = UiKit.Skin(UiKit.Fill("Glow", box, -6f, -6f, -6f, -6f), "card", Col("ring", UiKit.Coin));
glow.gameObject.AddComponent<UiPulse>();
}
var bt = box.gameObject.AddComponent<Button>();
var step = s;
bt.onClick.AddListener(() => OnBox(kind, step));
var ic = UiKit.Icon(box, icon, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 2f), 78f);
if (ic != null && got) ic.color = new Color(0.45f, 0.45f, 0.5f, 1f);
if (got) UiKit.Icon(box, Cfg("check_icon", "check"), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(6f, -4f), 64f);
if (ready)
{
var tag = UiKit.Skin(UiKit.Rect("Ready", box, new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), new Vector2(0f, -2f), new Vector2(84f, 34f)), "chip", Col("badge", UiKit.Red));
UiKit.Title(UiKit.FillLabel(tag.transform, T("box_ready"), 22, UiKit.White), true);
}
UiKit.Title(UiKit.Label(panel, s.need.ToString(CultureInfo.InvariantCulture), 28, Col("text", UiKit.White), TextAnchor.MiddleCenter, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(x, -206f), new Vector2(120f, 36f)), true);
}
string note = kind == MissionDb.Daily ? F("note_Daily", max.ToString(CultureInfo.InvariantCulture)) : WeeklyNote(db, max);
Txt(panel, "Note", note, 23, Col("text_dim", UiKit.InkSoft), X0, 222f, W + 40f, 30f, TextAnchor.MiddleLeft, false);
// 줄 목록
ScrollRect sr;
var grid = UiKit.ScrollGrid("Rows", page, 24f, 24f, 282f, BottomH, new Vector2(RowW, RowH), new Vector2(0f, 12f), 1, out sr);
foreach (var r in MissionRules.Rows(og, d, kind)) MissionRow(grid, kind, r);
Bottom(T("foot_" + kind), () => OnClaimAll(kind));
}
static string WeeklyNote(MissionDb db, int max)
{
DayOfWeek dow;
int hour;
MissionRules.ParseWeekly(db.Value("weekly_reset"), out dow, out hour);
return F("note_Weekly", T("day_" + dow.ToString().Substring(0, 3)), hour.ToString(CultureInfo.InvariantCulture), max.ToString(CultureInfo.InvariantCulture));
}
void MissionRow(RectTransform grid, string kind, MissionRow r)
{
var m = r.m;
string state = r.claimed ? "done" : r.done ? "claim" : m.go != "none" ? "go" : "wait";
RowStates.Add(state);
RowTitles.Add(m.titleKo);
var row = Cell(grid, "Row_" + m.id, r.claimed ? Col("row_done", UiKit.Dark) : Col("row", UiKit.Dark));
float doneA;
if (r.claimed && float.TryParse(Cfg("done_alpha"), NumberStyles.Float, CultureInfo.InvariantCulture, out doneA))
row.gameObject.AddComponent<CanvasGroup>().alpha = Mathf.Clamp01(doneA); // 받은 줄 = 통째로 흐림(목업 done · 표 done_alpha)
IconBox(row, "Ic", Cfg("icon." + m.counter), 20f, 8f, 84f);
var dim = Col("text_dim", UiKit.InkSoft);
var title = Txt(row, "Title", m.titleKo, 32, r.claimed ? dim : Col("text", UiKit.White), 124f, 6f, 600f, 46f, TextAnchor.MiddleLeft, true);
bool alt = m.role == MissionDb.Fallback;
if (alt)
{
float tw = Mathf.Min(560f, Mathf.Ceil(title.preferredWidth));
var tag = UiKit.Skin(UiKit.At(row, "Alt", 124f + tw + 12f, 13f, 68f, 34f), "chip", Col("alt", UiKit.Red));
UiKit.Title(UiKit.FillLabel(tag.transform, T("alt_badge"), 22, UiKit.White), true);
}
Progress(row, r.count, m.goal, 126f, 72f, 250f, 24f);
string hint = m.hintKo;
if (alt)
{
var main = S.Db.Missions.MainOf(m);
if (main != null) hint = F("alt_hint", MissionRules.CfgRef(main.unlock), main.titleKo);
}
var h = Txt(row, "Hint", hint, 24, dim, 392f, 54f, 360f, 36f, TextAnchor.MiddleLeft, false);
h.horizontalOverflow = HorizontalWrapMode.Wrap;
h.verticalOverflow = VerticalWrapMode.Truncate;
var pt = UiKit.Skin(UiKit.At(row, "Pt", 760f, 22f, 100f, 56f), "chip", Col("chip", UiKit.Dark));
UiKit.Title(UiKit.FillLabel(pt.transform, F("point_plus", m.point.ToString(CultureInfo.InvariantCulture)), 30, r.claimed ? dim : Col("text_gold", UiKit.Coin)), true);
int id = m.id;
switch (state)
{
case "claim": RowBtn(row, "btn_l_yellow", UiKit.White, T("btn_claim"), UiKit.Col("text_on_yellow", UiKit.Ink), () => OnClaim(kind, id)); break;
case "go": RowBtn(row, "btn_sky", UiKit.White, T("btn_go"), UiKit.White, () => Go(m.go)); break;
case "done": DoneBtn(row, T("btn_done")); break;
default: RowBtn(row, "btn_s_gray", UiKit.White, T("btn_wait"), UiKit.White, null).interactable = false; break;
}
}
// ---------- 업적 ----------
void BuildAchievements()
{
var og = S.Db;
var db = og.Missions;
var d = S.Save;
var cats = new List<string> { "" };
foreach (var a in db.achievements)
if (!cats.Contains(a.category)) cats.Add(a.category);
float x = 24f;
foreach (var c in cats)
{
string label = T(c.Length == 0 ? "ach_cat_all" : "ach_cat_" + c);
var chip = UiKit.At(page, "Cat_" + (c.Length == 0 ? "all" : c), x, 4f, 100f, 58f);
UiKit.Skin(chip, "chip", c == cat ? Col("cat_on", UiKit.Red) : Col("panel", UiKit.Dark), true);
var t = UiKit.Title(UiKit.FillLabel(chip, label, 27, UiKit.White), true);
float w = Mathf.Ceil(t.preferredWidth) + 48f;
chip.sizeDelta = new Vector2(w, 58f);
string cc = c;
chip.gameObject.AddComponent<Button>().onClick.AddListener(() => SetCategory(cc));
x += w + 12f;
}
Txt(page, "Count", F("ach_count", db.achievements.Count.ToString(CultureInfo.InvariantCulture)), 22, Col("text_dim", UiKit.InkSoft), x, 16f, 1056f - x, 34f, TextAnchor.MiddleRight, false);
ScrollRect sr;
var grid = UiKit.ScrollGrid("Rows", page, 24f, 24f, 78f, BottomH, new Vector2(RowW, AchH), new Vector2(0f, 10f), 1, out sr);
foreach (var r in MissionRules.AchRows(og, d, cat)) AchRow(grid, r);
Bottom(T("foot_achieve"), OnAchAll);
}
void AchRow(RectTransform grid, AchRow r)
{
var a = r.a;
string state = r.allDone ? "done" : r.Claimable ? "claim" : "wait";
RowStates.Add(state);
RowTitles.Add(a.nameKo);
var row = Cell(grid, "Ach_" + a.id, Col("row", UiKit.Dark));
IconBox(row, "Ic", Cfg("icon." + a.counter), 20f, 18f, 96f);
var white = Col("text", UiKit.White);
var dim = Col("text_dim", UiKit.InkSoft);
var name = Txt(row, "Name", a.nameKo, 32, white, 136f, 8f, 420f, 44f, TextAnchor.MiddleLeft, true);
float nw = Mathf.Min(400f, Mathf.Ceil(name.preferredWidth));
string stepText = r.allDone ? T("ach_all_done") : r.repeat ? F("ach_step_repeat", r.step.ToString(CultureInfo.InvariantCulture)) : F("ach_step", r.step.ToString(CultureInfo.InvariantCulture), a.goals.Length.ToString(CultureInfo.InvariantCulture));
var tag = UiKit.Skin(UiKit.At(row, "Step", 136f + nw + 12f, 13f, 150f, 34f), "chip", Col("tag", UiKit.Dark));
var tt = UiKit.Title(UiKit.FillLabel(tag.transform, stepText, 22, UiKit.White), true);
tag.rectTransform.sizeDelta = new Vector2(Mathf.Ceil(tt.preferredWidth) + 30f, 34f);
Txt(row, "Desc", a.descKo.Replace("{n}", r.goal.ToString("N0", CultureInfo.InvariantCulture)), 24, dim, 136f, 52f, 600f, 34f, TextAnchor.MiddleLeft, false);
Progress(row, r.value, r.goal, 138f, 106f, 330f, 24f, false); // 업적 = 쌓인 값 그대로(목업 「120 / 50」)
if (r.Claimable)
{
var next = MissionRules.AchAt(S.Db, S.Save, a, Counts.Get(S.Save.mission.achieve, a.id) + 1);
if (!next.allDone && r.value >= next.goal)
Txt(row, "Next", F("ach_next_also", next.step.ToString(CultureInfo.InvariantCulture), next.goal.ToString("N0", CultureInfo.InvariantCulture)), 22, Col("text_gold", UiKit.Coin), 486f, 92f, 300f, 30f, TextAnchor.MiddleLeft, false);
}
if (!r.allDone)
{
var gi = UiKit.Icon(row, Cfg("gem_icon", "cur_gem"), new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(822f, -60f), 62f);
if (gi != null) UiKit.DropShadow(gi, 3f);
var q = UiKit.Title(UiKit.Label(row, r.gem.ToString(CultureInfo.InvariantCulture), 26, white, TextAnchor.MiddleCenter, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(846f, -94f), new Vector2(60f, 30f)), true);
q.horizontalOverflow = HorizontalWrapMode.Overflow;
}
string id = a.id;
switch (state)
{
case "claim": RowBtn(row, "btn_l_yellow", UiKit.White, T("btn_claim"), UiKit.Col("text_on_yellow", UiKit.Ink), () => OnAchClaim(id), 32f); break;
case "done": DoneBtn(row, T("btn_done"), 32f); break;
default: RowBtn(row, "btn_s_gray", UiKit.White, T("btn_wait"), UiKit.White, null, 32f).interactable = false; break;
}
}
// ---------- 동작 ----------
void OnClaim(string kind, int id)
{
int p = MissionRules.Claim(S.Db, S.Save, kind, id);
if (p <= 0) return;
S.Commit();
Root.Toast(F("pop_all_points", p.ToString(CultureInfo.InvariantCulture)));
}
public void OnBox(string kind, MissionDb.PointReward s)
{
var got = MissionRules.ClaimBox(S.Db, S.Save, kind, s.step, S.Rng);
if (got == null) return;
S.Commit();
var content = Popup(F("pop_box_title_" + kind, s.need.ToString(CultureInfo.InvariantCulture)), 640f, "pop_gold");
RewardRow(content, got, 20f, 130f, true);
MissionDb.PointReward next = null;
foreach (var x in S.Db.Missions.Steps(kind))
if (x.step > s.step)
{
next = x;
break;
}
string tail = next != null ? F("pop_box_next", next.need.ToString(CultureInfo.InvariantCulture)) : T("pop_box_last");
UiKit.Label(content, tail, 28, UiKit.InkSoft, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -250f), new Vector2(820f, 44f), false);
}
public void OnClaimAll(string kind)
{
int pts;
var got = MissionRules.ClaimAll(S.Db, S.Save, kind, S.Rng, out pts);
if (pts <= 0 && got.Count == 0)
{
Root.Toast(T("pop_nothing"));
return;
}
S.Commit();
var parts = new List<string>();
foreach (var g in got) parts.Add(g.reward);
var content = Popup(T("pop_all_title"), parts.Count > 0 ? 660f : 480f, "pop_gold");
UiKit.Title(UiKit.Label(content, F("pop_all_points", pts.ToString(CultureInfo.InvariantCulture)), 34, UiKit.Ink, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -8f), new Vector2(820f, 50f)), false);
if (parts.Count > 0) RewardRow(content, MissionRules.Merge(parts), 80f, 120f, true);
}
void OnAchClaim(string id)
{
var a = S.Db.Missions.Ach(id);
var r = a != null ? MissionRules.AchOf(S.Db, S.Save, a) : null;
if (r == null || MissionRules.ClaimAch(S.Db, S.Save, id) <= 0) return;
S.Commit();
ChainPopup(new List<AchClaim> { new AchClaim { a = a, step = r.step, goal = r.goal, gem = r.gem } });
}
public void OnAchAll()
{
var got = MissionRules.ClaimAllAch(S.Db, S.Save);
if (got.Count == 0)
{
Root.Toast(T("pop_nothing"));
return;
}
S.Commit();
ChainPopup(got);
}
void ChainPopup(List<AchClaim> got)
{
int total = 0;
foreach (var g in got) total += g.gem;
// 연쇄 설명 = 한 종류에서 2단계 이상 받은 첫 업적
string chain = null;
var seen = new Dictionary<string, List<int>>();
foreach (var g in got)
{
List<int> l;
if (!seen.TryGetValue(g.a.id, out l)) seen[g.a.id] = l = new List<int>();
l.Add(g.step);
}
foreach (var kv in seen)
{
if (kv.Value.Count < 2) continue;
var a = S.Db.Missions.Ach(kv.Key);
var now = MissionRules.AchOf(S.Db, S.Save, a);
var steps = new List<string>();
foreach (var s in kv.Value) steps.Add(s.ToString(CultureInfo.InvariantCulture));
chain = F("pop_ach_chain", a.nameKo, now.value.ToString("N0", CultureInfo.InvariantCulture), string.Join("·", steps.ToArray()), now.step.ToString(CultureInfo.InvariantCulture), now.goal.ToString("N0", CultureInfo.InvariantCulture));
break;
}
int shown = Mathf.Min(got.Count, 6);
float h = 300f + shown * 106f + (chain != null ? 90f : 0f) + 70f;
var content = Popup(T("pop_ach_title"), Mathf.Min(1500f, h), "pop_gold");
RectTransform list = content;
if (got.Count > shown)
{
ScrollRect sr;
list = UiKit.ScrollGrid("Lines", content, 0f, 0f, 0f, 70f + (chain != null ? 90f : 0f), new Vector2(860f, 96f), new Vector2(0f, 10f), 1, out sr);
}
for (int i = 0; i < got.Count; i++)
{
var g = got[i];
RectTransform line;
if (list == content) line = UiKit.At(content, "Line" + i, 0f, i * 106f, 860f, 96f);
else line = Cell(list, "Line" + i, Color.white);
UiKit.Skin(line, "panel12", Col("row", UiKit.Dark)); // 팝업 판 = 어두운 테마 → 줄도 어둡게 · 흰 글자(목업 pn2)
IconBox(line, "Ic", Cfg("icon." + g.a.counter), 14f, 12f, 72f);
Txt(line, "Name", F("pop_ach_line", g.a.nameKo, g.step.ToString(CultureInfo.InvariantCulture)), 30, Col("text", UiKit.White), 102f, 8f, 560f, 42f, TextAnchor.MiddleLeft, true);
Txt(line, "Desc", g.a.descKo.Replace("{n}", g.goal.ToString("N0", CultureInfo.InvariantCulture)), 23, Col("text_dim", UiKit.InkSoft), 102f, 50f, 560f, 34f, TextAnchor.MiddleLeft, false);
UiKit.Icon(line, Cfg("gem_icon", "cur_gem"), new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(714f, -48f), 54f);
Txt(line, "Gem", F("point_plus", g.gem.ToString(CultureInfo.InvariantCulture)), 32, Col("text", UiKit.White), 746f, 26f, 110f, 44f, TextAnchor.MiddleLeft, true);
}
float y = list == content ? shown * 106f + 14f : content.rect.height - 70f - (chain != null ? 90f : 0f);
var sum = UiKit.At(content, "Sum", 0f, y, 860f, 60f);
Txt(sum, "Label", T("pop_ach_sum"), 34, Col("text", UiKit.White), 250f, 4f, 120f, 52f, TextAnchor.MiddleRight, true);
UiKit.Icon(sum, Cfg("gem_icon", "cur_gem"), new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(410f, -30f), 62f);
Txt(sum, "Total", F("point_plus", total.ToString(CultureInfo.InvariantCulture)), 44, Col("text_gold", UiKit.Coin), 450f, 0f, 260f, 60f, TextAnchor.MiddleLeft, true);
if (chain != null) UiKit.Label(content, chain, 25, UiKit.InkSoft, TextAnchor.UpperCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -(y + 70f)), new Vector2(840f, 86f), false);
}
/// <summary>바로가기(mission_screen goto.&lt;낱말&gt; = map · hero · arena:쪽 · domestic:쪽 · trade:쪽 · treasure:쪽).</summary>
public void Go(string go)
{
var target = Cfg("goto." + go);
int colon = target.IndexOf(':');
string scr = colon > 0 ? target.Substring(0, colon) : target;
int pg = 0;
if (colon > 0) int.TryParse(target.Substring(colon + 1), NumberStyles.Integer, CultureInfo.InvariantCulture, out pg);
switch (scr)
{
case "map": Root.OpenWorldMap(); break;
case "hero": Root.Show(Root.HeroList); break;
case "arena":
Root.Arena.SetPage(pg);
Root.Show(Root.Arena);
break;
case "domestic":
Root.Show(Root.Domestic);
Root.Domestic.SetPage(pg);
break;
case "trade":
Root.Show(Root.Trade);
Root.Trade.SetPage(pg);
break;
case "treasure":
Root.Show(Root.Treasures);
Root.Treasures.SetPage(pg);
break;
}
}
// ---------- 부품 ----------
RectTransform Popup(string title, float h, string headColor)
{
LastPopup = title;
var content = Root.ModalCustom(title, h, new OutGameRoot.ModalButton(T("pop_ok"), UiKit.Col("ok", UiKit.Ok), null));
var head = content.parent.Find("Head");
if (head != null && head.GetComponent<Image>() != null) head.GetComponent<Image>().color = Col(headColor, UiKit.Header);
return content;
}
/// <summary>보상 아이콘 줄(가운데 정렬 · 아이콘 + 수량 + 이름).</summary>
public static void RewardRow(RectTransform p, string reward, float y, float size, bool names)
{
var map = ContentTables.ParseMap(reward);
float gap = size + 60f;
float x0 = -(map.Count - 1) * gap * 0.5f;
int i = 0;
foreach (var kv in map)
{
var cell = UiKit.Rect("Rw_" + kv.Key, p, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(x0 + i * gap, -y), new Vector2(size, size));
UiKit.Skin(cell, "panel12", new Color(0.24f, 0.27f, 0.42f));
var ic = UiKit.Icon(cell, Cfg("reward_icon." + kv.Key), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 4f), size * 0.72f);
if (ic != null) UiKit.DropShadow(ic, 3f);
UiKit.QtyChip(cell, Mathf.RoundToInt(kv.Value).ToString("N0", CultureInfo.InvariantCulture), size >= 110f ? 28 : 22);
if (names)
UiKit.Label(p, T("reward_" + kv.Key), size >= 110f ? 28 : 22, UiKit.Ink, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(x0 + i * gap, -(y + size + 14f)), new Vector2(gap, 38f));
i++;
}
}
void Timer(RectTransform panel, string kind)
{
var chip = UiKit.Skin(UiKit.Rect("Timer", panel, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-24f, -14f), new Vector2(340f, 54f)), "chip", Col("chip", UiKit.Dark));
UiLayer.Nest(chip.gameObject, UiRate.Event, false); // 1초마다 글자만 바뀜 = 판 캔버스와 따로
var ic = UiKit.Icon(chip.transform, Cfg("timer_icon", "clock"), new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(30f, 0f), 44f);
if (ic != null) UiKit.DropShadow(ic, 2f);
var t = UiKit.Title(UiKit.Label(chip.transform, "", 26, UiKit.White, TextAnchor.MiddleLeft, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(60f, 1f), new Vector2(270f, 50f)), true);
t.horizontalOverflow = HorizontalWrapMode.Overflow;
var mt = chip.gameObject.AddComponent<MissionTimer>();
mt.Init(this, kind, t);
}
/// <summary>남은 시간 글(일일 = 시:분:초 · 주간 = 일 시:분).</summary>
public string ResetText(string kind)
{
var left = MissionRules.UntilReset(S.Db.Missions, kind, S.Now);
if (left < TimeSpan.Zero) left = TimeSpan.Zero;
string s = kind == MissionDb.Daily
? F("reset_hms", ((int)left.TotalHours).ToString("00"), left.Minutes.ToString("00"), left.Seconds.ToString("00"))
: F("reset_dhm", left.Days.ToString(CultureInfo.InvariantCulture), left.Hours.ToString("00"), left.Minutes.ToString("00"));
return F("reset_in", s);
}
void Bottom(string foot, Action all)
{
float pageH = OutGameRoot.BodyH - 116f;
Txt(page, "Foot", foot, 24, Col("text_dim", UiKit.InkSoft), 24f, pageH - 118f, 620f, 90f, TextAnchor.MiddleLeft, false).lineSpacing = 1.1f;
var b = UiKit.SkinBtn(page, "ClaimAll", "btn_l_yellow", UiKit.White, T("claim_all"), 44, UiKit.Col("text_on_yellow", UiKit.Ink), 1056f - 380f, pageH - 122f, 380f, 104f, all);
b.name = "ClaimAll";
}
static RectTransform Cell(RectTransform grid, string name, Color c)
{
var go = new GameObject(name, typeof(RectTransform));
go.transform.SetParent(grid, false);
var rt = (RectTransform)go.transform;
UiKit.Skin(rt, "panel12", c, true);
return rt;
}
static void IconBox(RectTransform row, string name, string icon, float x, float y, float s)
{
var box = UiKit.At(row, name, x, y, s, s);
UiKit.Skin(box, "panel12", Col("chip", UiKit.Dark));
var ic = UiKit.Icon(box, icon, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, s * 0.78f);
if (ic != null) UiKit.DropShadow(ic, 2f);
}
static void Progress(RectTransform row, int v, int goal, float x, float y, float w, float h, bool clamp = true)
{
bool full = v >= goal;
var fill = UiKit.Bar("Bar", row, new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(x, -y), new Vector2(w, h), Col("chip", UiKit.Dark), full ? Col("bar_full", UiKit.Coin) : Col("bar_part", UiKit.Jade));
UiKit.SetBar(fill, goal > 0 ? v / (float)goal : 0f);
var t = UiKit.Title(UiKit.Label(row, F("progress", (clamp ? Mathf.Min(v, goal) : v).ToString("N0", CultureInfo.InvariantCulture), goal.ToString("N0", CultureInfo.InvariantCulture)), 20, UiKit.White, TextAnchor.MiddleCenter, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(x + w * 0.5f, -y), new Vector2(w, h + 6f)), true);
t.name = "ProgressText";
t.horizontalOverflow = HorizontalWrapMode.Overflow;
}
static Button RowBtn(RectTransform row, string skin, Color tint, string label, Color fg, Action onClick, float y = 16f)
{
var b = UiKit.SkinBtn(row, "Btn", UISkin.Has(skin) ? skin : "button", tint, label, 32, fg, 880f, y, 136f, 68f, onClick);
return b;
}
static void DoneBtn(RectTransform row, string label, float y = 16f)
{
var b = RowBtn(row, "btn_s_gray", UiKit.White, label, UiKit.White, null, y);
b.interactable = false;
var t = UiKit.LabelOf(b);
t.rectTransform.offsetMin = new Vector2(46f, t.rectTransform.offsetMin.y);
var ic = UiKit.Icon(b.transform, Cfg("check_icon", "check"), new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(34f, 4f), 40f);
if (ic != null) ic.color = UiKit.Col("ok", UiKit.Ok);
}
static Text Txt(RectTransform p, string name, string s, int size, Color c, float x, float y, float w, float h, TextAnchor align, bool title)
{
var t = UiKit.Label(p, s, size, c, align, 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 List<string> Split(string s)
{
var l = new List<string>();
foreach (var p in (s ?? "").Split(';'))
if (p.Trim().Length > 0) l.Add(p.Trim());
return l;
}
}
/// <summary>초기화 시계 칩 글자(1초마다 · 값이 같으면 Text 가 쓰지 않음).</summary>
public class MissionTimer : MonoBehaviour
{
MissionScreen screen;
string kind;
Text text;
float next;
public void Init(MissionScreen s, string k, Text t)
{
screen = s;
kind = k;
text = t;
text.text = s.ResetText(k);
}
void Update()
{
if (screen == null || text == null || Time.unscaledTime < next) return;
next = Time.unscaledTime + 1f;
text.text = screen.ResetText(kind);
}
}
}