108 lines
6.5 KiB
C#
108 lines
6.5 KiB
C#
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
namespace TKS.OutGame
|
||
{
|
||
/// <summary>
|
||
/// 본영 로비(img03 · 기획 S4) — 진행 칩 · 출전 편성 5인 · 중앙 큰 「출정」(→ 챕터 월드맵) · 좌 「편성」 · 우 「연무장」(PD #1093 C) · 하단 탭 5.
|
||
/// </summary>
|
||
public class LobbyScreen : OutGameScreen
|
||
{
|
||
Text progress;
|
||
RectTransform field;
|
||
|
||
public override void Build()
|
||
{
|
||
Header("본영", "로비", false);
|
||
var body = Body();
|
||
|
||
// 배경 = 테마 bg_lobby(키아트 04 · 어둡게 · 신규 제작 로비 배경이 오면 치환) · 없으면 땅 색 판
|
||
var art = UISkin.Icon("bg_lobby");
|
||
if (art != null)
|
||
{
|
||
var clip = UiKit.Fill("LobbyBg", body);
|
||
clip.gameObject.AddComponent<RectMask2D>();
|
||
// 위쪽 맞춤 × 1.22 — 키아트 아래쪽 아군 5인은 잘라 내고(편성 5인과 겹치지 않게) 전장·적진만 보이게
|
||
var art2 = UiKit.Rect("Art", clip, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, Vector2.zero);
|
||
art2.anchorMin = new Vector2(-0.11f, 1f);
|
||
art2.anchorMax = new Vector2(1.11f, 1f);
|
||
art2.offsetMin = art2.offsetMax = Vector2.zero;
|
||
var bimg = art2.gameObject.AddComponent<Image>();
|
||
bimg.sprite = art;
|
||
bimg.color = UISkin.Col("lobby_tint", Color.white);
|
||
bimg.raycastTarget = false;
|
||
var fit = bimg.gameObject.AddComponent<AspectRatioFitter>();
|
||
fit.aspectMode = AspectRatioFitter.AspectMode.WidthControlsHeight;
|
||
fit.aspectRatio = art.rect.width / Mathf.Max(1f, art.rect.height);
|
||
}
|
||
|
||
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);
|
||
if (art == null) 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), false);
|
||
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 = "";
|
||
var si = UiKit.Icon(sortie.transform, "btn_sortie", new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -26f), 92f);
|
||
if (si != null) UISkin.Stroke(si, UiKit.Stroke, 3f);
|
||
else 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.Title(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)), true);
|
||
int stages = Root.Battle != null ? Root.Battle.Config.stages.Length : 0;
|
||
UiKit.Title(UiKit.Label(sortie.transform, "챕터 월드맵\n" + stages + " 스테이지", 34, UiKit.White, TextAnchor.MiddleCenter, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 34f), new Vector2(420f, 100f), false), true);
|
||
|
||
SideButton(body, "Formation", "btn_formation", "편", "편성", "출정 좌측", -1, () => Root.Show(Root.Formation));
|
||
SideButton(body, "Arena", "btn_arena", "연", "연무장", "출정 우측", 1, () =>
|
||
{
|
||
Root.Arena.SetPage(0);
|
||
Root.Show(Root.Arena); // 연무장(PD #1093 C)
|
||
});
|
||
}
|
||
|
||
void SideButton(RectTransform body, string name, string icon, 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);
|
||
if (UiKit.Icon(dot.transform, icon, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 66f) == null) UiKit.FillLabel(dot.transform, mark, 50, UiKit.White);
|
||
UiKit.Title(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, 34f), 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));
|
||
}
|
||
}
|
||
}
|
||
}
|