ThreeKingdomsSlingshot/Assets/Scripts/OutGame/UI/LobbyScreen.cs

82 lines
4.9 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 본영 로비(img03 · 기획 S4) — 진행 칩 · 출전 편성 5인 · 중앙 큰 「출정」(→ 챕터 월드맵) · 좌 「편성」 · 우 「연무장」(준비 중) · 하단 탭 5.
/// </summary>
public class LobbyScreen : OutGameScreen
{
Text progress;
RectTransform field;
public override void Build()
{
Header("본영", "로비", false);
var body = Body();
var chip = UiKit.Box("Progress", body, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -28f), new Vector2(760f, 84f), UiKit.Paper);
UiKit.Border(chip, UiKit.Line, 2f);
progress = UiKit.FillLabel(chip.transform, "", 34, UiKit.Ink);
// 전장 자리(배경 아트 없음 → 땅 색 판) · 출전 편성 5인
var ground = UiKit.Fill("Field", body, 24f, 24f, 140f, 520f);
UiKit.Paint(ground, new Color(0.47f, 0.52f, 0.36f));
var shadow = UiKit.Box("Shadow", ground, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 70f), new Vector2(940f, 150f), new Color(0.2f, 0.18f, 0.14f, 0.55f));
shadow.sprite = UiKit.Circle;
shadow.type = Image.Type.Simple;
field = UiKit.Fill("Lineup", ground, 20f, 20f, 40f, 40f);
float y = 40f;
var sortie = UiKit.Btn("Sortie", body, "", 40, UiKit.Red, UiKit.White, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, y), new Vector2(440f, 400f), () => Root.OpenWorldMap());
UiKit.Border(sortie.GetComponent<Image>(), new Color(0.98f, 0.86f, 0.7f), 5f);
UiKit.LabelOf(sortie).text = "";
UiKit.Label(sortie.transform, "로비 중앙", 28, new Color(1f, 0.85f, 0.8f), TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -22f), new Vector2(400f, 50f), false);
UiKit.Label(sortie.transform, "출정", 120, UiKit.White, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 30f), new Vector2(420f, 170f));
int stages = Root.Battle != null ? Root.Battle.Config.stages.Length : 0;
UiKit.Label(sortie.transform, "챕터 월드맵\n" + stages + " 스테이지", 34, UiKit.White, TextAnchor.MiddleCenter, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 30f), new Vector2(420f, 100f), false);
SideButton(body, "Formation", "편", "편성", "출정 좌측", -1, () => Root.Show(Root.Formation));
SideButton(body, "Arena", "연", "연무장", "출정 우측", 1, () => Root.ComingSoon("연무장 (탑 · 일일 던전 · 투기장 · 적장 토벌)"));
}
void SideButton(RectTransform body, string name, string mark, string title, string sub, int side, System.Action onClick)
{
float x = side * (220f + 160f);
var b = UiKit.Btn(name, body, "", 30, UiKit.Paper, UiKit.Ink, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(x, 70f), new Vector2(290f, 340f), onClick);
UiKit.Border(b.GetComponent<Image>(), UiKit.Line, 3f);
var dot = UiKit.Dot("Mark", b.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -36f), 110f, UiKit.Dark);
UiKit.FillLabel(dot.transform, mark, 50, UiKit.White);
UiKit.Label(b.transform, title, 52, UiKit.Ink, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -40f), new Vector2(280f, 80f));
UiKit.Label(b.transform, sub, 28, UiKit.InkSoft, TextAnchor.MiddleCenter, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 30f), new Vector2(280f, 50f), false);
}
public override void Refresh()
{
var map = Root.Map;
var cfg = Root.Battle.Config;
if (map != null && map.HasData)
{
int ch = Root.CurrentChapter();
int node = Mathf.Min(WorldProgress.Cleared(ch), Mathf.Max(0, map.NodesIn(ch) - 1));
int si = map.StageIndexOf(ch, node);
var def = cfg.chapters[ch];
progress.text = "현재 진행: 제" + def.no + "장 " + def.title + (si >= 0 ? " · " + def.no + "-" + cfg.stages[si].stage : "");
}
else progress.text = "현재 진행: —";
UiKit.Clear(field);
var lineup = S.BuildLineup();
int n = Mathf.Max(1, lineup.Count);
float w = Mathf.Min(200f, 980f / n);
for (int i = 0; i < lineup.Count; i++)
{
var h = S.Def(lineup[i].id);
float x = (i - (n - 1) / 2f) * w;
UiKit.Portrait("Hero" + i, field, h, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(x, 20f), new Vector2(w, 340f), false, 1f, new Color(1f, 1f, 1f, 0f));
}
}
}
}