using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace TKS
{
///
/// 전투 HUD(uGUI · 코드 생성 · 출정 · 연의 전기 · 서장 · 투기장 · 탑 공통) — PD 2026-11-21 재설계 「군막 지휘판」(아트 폴더 battle_ui/design/디자인기획_r1.md · Fable):
/// 위 = 남색 크롬 전황 띠(왼쪽 위 중단 버튼 · 스테이지 이름 · 아군/적 수) + 옻칠 턴 현판(아군 남색 · 적 붉은색) · 오른쪽 위 금 테 미니맵 ·
/// 아래 = 지휘 탁자(선택 영웅 정보) + 영웅을 터치하면 솟는 스킬 버튼(아이콘 + 이름표 + 상태 · 쿨) + 별도 목패 스킬 설명 칸 · 중단 팝업(계속 / 포기 = 패배).
/// 배치 · 그림 · 색 = 표 · 글자 = 표 (코드 상수 0) · 모든 글자 = 제목 글꼴(UiFontUnify).
/// 캔버스 층(PD 2026-11-10): 루트 = 정적 판(위 띠 · 중단 버튼 · 수 칩 판 · 미니맵 틀 · Static) → Info(글자 · 값 · 턴 현판 · 탁자 · 스킬 · 설명 · Event)
/// → MinimapLive(시야 · 점 · Frame) · 스킬 번짐(호흡 · 자기 Frame) → Result(결과 덮개 · Event) · 중단 팝업 = 자기 루트 캔버스.
///
public class BattleHUD : MonoBehaviour
{
public const string LayoutTable = "UI/Battle/battle_hud";
public const string TextTable = "UI/Battle/battle_text";
const float RefW = 1080f;
const float RefH = 1920f;
BattleManager battle;
Camera uiCam;
CameraController camCtrl;
readonly Dictionary lay = new Dictionary();
Color strokeCol;
float strokeCap = -1f; // ≥ 0 = 종이 위 글자(표 desk_text 테 두께 · 0 = 없음)
Color deskInk = Color.white; // 종이 위 글자 색(표 desk_text)
/// 종이(두루마리) 위 글자 모드 켜기/끄기 — 먹 글자 + 밝은 얇은 테(표 desk_text · PD 2026-11-21 7차 1안 「펼친 군령 두루마리」).
void PaperText(bool on)
{
if (on && L("desk_text").Length > 0)
{
deskInk = C("desk_text", 0, new Color(0.29f, 0.18f, 0.1f));
strokeCol = C("desk_text", 1, new Color(1f, 0.96f, 0.86f));
strokeCap = N("desk_text", 2, 1f);
}
else
{
deskInk = Color.white;
strokeCol = C("stroke", 0, new Color(0.12f, 0.13f, 0.2f));
strokeCap = -1f;
}
}
CanvasGroup group;
Unit selected;
/// 결과 패널이 따로 있으면(아웃게임) 결과 단계에서 HUD 전체를 숨긴다(검수 결함 1 · 제목 2중 방지).
public bool HideOnResult;
// 층
RectTransform info;
RectTransform resultLayer;
// 위 전황 띠
RectTransform pauseBtn; // 설정 버튼(오른쪽 끝 톱니 · 누름 = 중단 팝업)
Text stageText;
Text stageSub;
Text allyCount;
Text enemyCount;
Image turnPlaque;
Text turnText;
Sprite turnAllySprite;
Sprite turnEnemySprite;
BattlePhase lastPhase = BattlePhase.Setup;
float turnPopAt = -10f;
Image toast;
Text toastText;
string lastMsg = "";
float msgAt = -10f;
Image logChip;
Text skillLog;
// 미니맵
Image minimapBg;
Image minimapView;
RectTransform minimapLive;
readonly Dictionary minimapDots = new Dictionary();
// 아래 지휘 탁자
RectTransform desk;
RectTransform deskBody;
Text deskHint;
float deskFullH;
float deskLowH;
Image portraitRing;
Image portraitArt;
Image typeIcon;
Text nameText;
Image sideChip;
Text sideText;
RectTransform hpFill;
Image hpFillImg;
float hpFillW;
float hpFillMin = 12f; // 채움 최소 폭(둥근 채움 그림 = 높이만큼)
Text hpText;
Text atkText;
Text defText;
Text extraText;
RectTransform passiveLine;
Image passiveIcon;
Text skillPassive;
Text passiveDesc;
RectTransform passiveGroup;
Image portraitBack; // 초상 원 바탕 = 진영 색(금 고리 틀 안)
Unit shownUnit;
// 스킬 버튼
Image skillPanel; // Info/SkillButton = 누름 칸(학습 안내 TutorialDirector 가 이 이름으로 찾음)
Image skillIcon;
Text skillCool;
Text skillCoolUnit;
Text skillName;
Image stateTag;
Text skillState;
Text skillTrigger; // 즉시 시전 / 행동 시 발동(PD 2026-11-21 2차)
RectTransform skillGlow;
RectTransform skillGlowOn;
Unit armedUnit; // 즉시 시전 스킬 첫 터치 = 설명 + 「한 번 더 터치하면 발동」(PD 2026-11-21 2차) · 두 번째 터치 = 발동
Vector3 skillBaseScale = Vector3.one;
float skillPopAt = -10f;
Unit skillShownFor;
SkillSystem.ActiveState skillStateShown;
string skillMsg; // 스킬 버튼 탭이 남긴 안내 문장(선택 · 상태가 바뀌면 닫음)
bool hideSkillMsg; // 쓸 수 없을 때 누름 = 설명 칸 · 아이콘 숫자가 같은 말을 하므로 안내 줄에는 안 띄움(QA r1 M1)
// 스킬 설명 칸
enum DescKind
{
None,
Active,
Passive
}
Image descPanel;
Image descIcon;
Text descName;
Text descKind;
Image descCool;
Text descCoolText;
Text descText;
string descKey = "";
DescKind timedKind;
float timedUntil;
Unit timedUnit;
// 결과
GameObject resultOverlay;
Text resultTitle;
Text resultSub;
// ---------- 표 ----------
void LoadLayout()
{
lay.Clear();
var rows = OutGame.UiText.Rows(LayoutTable);
if (rows == null)
{
Debug.LogWarning("[TKS] 전투 HUD 배치 표 없음: " + LayoutTable);
return;
}
foreach (var r in rows)
{
string k, v;
if (r.TryGetValue("key", out k) && k.Length > 0 && r.TryGetValue("value", out v)) lay[k] = v.Split('|');
}
}
string[] L(string key)
{
string[] a;
return lay.TryGetValue(key, out a) ? a : new string[0];
}
float N(string key, int i, float def)
{
var a = L(key);
float v;
return i < a.Length && float.TryParse(a[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out v) ? v : def;
}
string S(string key, int i, string def = "")
{
var a = L(key);
return i < a.Length && a[i].Trim().Length > 0 ? a[i].Trim() : def;
}
/// 색 칸 = #RRGGBB(AA) 또는 테마 색 키.
Color C(string key, int i, Color def)
{
string s = S(key, i);
if (s.Length == 0) return def;
Color c;
if (s[0] == '#') return ColorUtility.TryParseHtmlString(s, out c) ? c : def;
return UISkin.Col(s, def);
}
/// HUD 밖(전장 이름표 등)에서 배치 표 값 하나 읽기(전투 시작 때 몇 번만 · 매 프레임 금지).
public static float TableValue(string key, int i, float def)
{
var rows = OutGame.UiText.Rows(LayoutTable);
if (rows == null) return def;
foreach (var r in rows)
{
string k, v;
if (!r.TryGetValue("key", out k) || k != key || !r.TryGetValue("value", out v)) continue;
var a = v.Split('|');
float f;
return i < a.Length && float.TryParse(a[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out f) ? f : def;
}
return def;
}
static string T(string key)
{
return OutGame.UiText.T(key);
}
static string F(string key, params object[] args)
{
var a = new string[args.Length];
for (int i = 0; i < args.Length; i++) a[i] = System.Convert.ToString(args[i], CultureInfo.InvariantCulture);
return OutGame.UiText.F(key, a);
}
// ---------- 배치 도우미(표 좌표 = 1080×1920 · 왼쪽 위 0,0) ----------
/// 표 칸(붙는 곳|x|y|폭|높이)으로 사각을 만든다 — 붙는 곳 = T/B + L/R/C/S.
RectTransform Box(Transform parent, string key, string name)
{
var a = L(key);
string anchor = a.Length > 0 ? a[0].Trim() : "TL";
var rt = new GameObject(name, typeof(RectTransform)).GetComponent();
rt.SetParent(parent, false);
Place(rt, anchor, N(key, 1, 0f), N(key, 2, 0f), N(key, 3, 100f), N(key, 4, 50f));
return rt;
}
static void Place(RectTransform rt, string anchor, float x, float y, float w, float h)
{
char v = anchor.Length > 0 ? anchor[0] : 'T';
char hz = anchor.Length > 1 ? anchor[1] : 'L';
float ay = v == 'B' ? 0f : 1f;
float py = v == 'B' ? RefH - y - h : -y;
switch (hz)
{
case 'R':
rt.anchorMin = rt.anchorMax = new Vector2(1f, ay);
rt.pivot = new Vector2(1f, ay);
rt.anchoredPosition = new Vector2(-(RefW - x - w), py);
rt.sizeDelta = new Vector2(w, h);
break;
case 'C':
rt.anchorMin = rt.anchorMax = new Vector2(0.5f, ay);
rt.pivot = new Vector2(0.5f, ay);
rt.anchoredPosition = new Vector2(x + w * 0.5f - RefW * 0.5f, py);
rt.sizeDelta = new Vector2(w, h);
break;
case 'S':
rt.anchorMin = new Vector2(0f, ay);
rt.anchorMax = new Vector2(1f, ay);
rt.pivot = new Vector2(0f, ay);
rt.anchoredPosition = new Vector2(0f, py);
rt.sizeDelta = new Vector2(0f, h);
rt.offsetMin = new Vector2(x, rt.offsetMin.y);
rt.offsetMax = new Vector2(-(RefW - x - w), rt.offsetMax.y);
break;
default:
rt.anchorMin = rt.anchorMax = new Vector2(0f, ay);
rt.pivot = new Vector2(0f, ay);
rt.anchoredPosition = new Vector2(x, py);
rt.sizeDelta = new Vector2(w, h);
break;
}
}
/// 화면 가운데 기준 사각(팝업 · 표 x|y|폭|높이 = 1080×1920 좌표).
RectTransform Center(Transform parent, string key, string name)
{
float x = N(key, 0, 0f), y = N(key, 1, 0f), w = N(key, 2, 100f), h = N(key, 3, 50f);
return OutGame.UiKit.Rect(name, parent, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(x + w * 0.5f - RefW * 0.5f, RefH * 0.5f - (y + h * 0.5f)), new Vector2(w, h));
}
/// 제자리 그대로 피벗만 가운데로(크기 튐 연출이 가운데에서).
static void PivotCenter(RectTransform rt)
{
var d = new Vector2(0.5f, 0.5f) - rt.pivot;
var size = rt.rect.size.x > 0f ? rt.rect.size : rt.sizeDelta;
rt.pivot = new Vector2(0.5f, 0.5f);
rt.anchoredPosition += new Vector2(d.x * size.x, d.y * size.y);
}
/// 제목 글꼴 글자(외곽선 = 표 stroke 색 · 굵기 d · 0 = 없음).
Text Txt(Transform parent, string name, int size, Color c, TextAnchor align, float d)
{
var rt = OutGame.UiKit.Fill(name, parent);
var t = rt.gameObject.AddComponent();
UISkin.UseTitle(t);
t.fontSize = size;
t.alignment = align;
t.color = c;
t.supportRichText = true;
t.horizontalOverflow = HorizontalWrapMode.Wrap;
t.verticalOverflow = VerticalWrapMode.Overflow;
t.raycastTarget = false;
// 인게임 글자 외곽선 = 얇게(표 stroke 칸 2 · 3 = 작은 · 큰 글자 최대 · PD 2026-11-21 5차 「인게임 UI 에서는 아웃라인이 너무 두꺼우면 안됨」)
// 종이(두루마리) 위 글자 = 표 desk_text(먹 글자 + 밝은 얇은 테 · strokeCap ≥ 0 인 동안)
float cap = strokeCap >= 0f ? strokeCap : size >= 40 ? N("stroke", 2, 2.5f) : N("stroke", 1, 2f);
if (d > 0f && cap > 0f) UISkin.Stroke(t, strokeCol, Mathf.Min(d, cap));
return t;
}
/// 칸 안 맞춤 축소(Truncate 여야 최적 맞춤이 높이를 봄 · 2026-11-11 실측).
static Text Fit(Text t, int max, int min)
{
t.verticalOverflow = VerticalWrapMode.Truncate;
t.resizeTextForBestFit = true;
t.resizeTextMaxSize = max;
t.resizeTextMinSize = Mathf.Min(min, max);
return t;
}
static Image Art(RectTransform rt, string id, float ppu, Color c)
{
var img = rt.gameObject.AddComponent();
var sp = string.IsNullOrEmpty(id) ? null : UISkin.Icon(id);
img.sprite = sp;
img.color = c;
img.raycastTarget = false;
if (sp != null && sp.border != Vector4.zero)
{
img.type = Image.Type.Sliced;
img.pixelsPerUnitMultiplier = Mathf.Max(0.01f, ppu);
}
else img.preserveAspect = true;
if (sp == null && UISkin.Apply(img, "card")) img.color = UISkin.Col("hud_panel", new Color(0.12f, 0.15f, 0.21f, 0.9f)); // 그림이 없으면 팩 판
return img;
}
static void Show(Component c, bool on)
{
if (c != null && c.gameObject.activeSelf != on) c.gameObject.SetActive(on);
}
bool Hit(RectTransform rt, Vector2 screen)
{
return rt != null && rt.gameObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(rt, screen, uiCam);
}
// ---------- 만들기 ----------
public void Build(BattleManager b, Camera cam, CameraController cc)
{
battle = b;
uiCam = cam;
camCtrl = cc;
LoadLayout();
OutGame.UiText.Use(TextTable);
strokeCol = C("stroke", 0, new Color(0.12f, 0.13f, 0.2f));
UiLayer.Root(gameObject, cam, 100, 1f, UiLayer.Reference, UiRate.Static);
group = gameObject.AddComponent();
gameObject.AddComponent(); // 전투 화면에 본문 글꼴 0(나중에 생기는 글자 포함 · 기획 §5)
info = UiLayer.Group("Info", transform, UiRate.Event, false);
if (EventSystem.current == null && FindFirstObjectByType() == null)
{
var es = new GameObject("EventSystem");
es.AddComponent();
es.AddComponent();
}
BuildTop();
BuildMinimap();
BuildDesk();
BuildSkill();
BuildDesc();
BuildResult();
// 그리는 순서 = 정적 판(루트 자식들) → Info → Result
info.SetAsLastSibling();
resultLayer.SetAsLastSibling();
if (camCtrl != null)
{
camCtrl.TopHudRefPx = N("cam_hud", 0, 0f);
camCtrl.BottomHudRefPx = deskLowH + N("cam_hud", 1, 0f); // 이후 = 탁자 높이를 따라감(RefreshDesk)
}
}
void BuildTop()
{
// 띠 바탕(정적) = 아웃게임 제목 띠와 같은 판(보물 · 임무 · 이벤트 화면 · PD 2026-11-21 2차 「상단 UI 를 보물 · 출석부 화면 참고」) · 표 칸 6 = 위아래 뒤집기
var band = OutGame.UiKit.TopBand("TopBand", transform, N("top_band", 0, 0f), N("top_band", 1, 104f));
var bg = OutGame.UiKit.Fill("Bg", band);
if (N("top_band", 5, 0f) > 0.5f) bg.localScale = new Vector3(1f, -1f, 1f);
OutGame.UiKit.Skin(bg, S("top_band", 2, "header_bar"), C("top_band", 3, C("top_band", 4, OutGame.UiKit.Header)));
// 설정 버튼(오른쪽 끝 · 로비 본영 제목 띠 톱니와 같은 모양 · PD 2026-11-21 2차) · 누름 = 중단 팝업(SlingshotInput → TryGiveUpTap) · 정적
pauseBtn = Box(transform, "settings_btn", "Settings");
string ps = S("settings_btn_art", 0);
if (ps.Length > 0) OutGame.UiKit.Skin(pauseBtn, ps, C("settings_btn_art", 1, Color.white));
var pi = OutGame.UiKit.Icon(pauseBtn, S("settings_btn_art", 2, "lobby_option"), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, N("settings_btn_art", 3, 72f));
if (pi != null) OutGame.UiKit.DropShadow(pi, 3f);
pauseBtn.gameObject.SetActive(false);
// 스테이지 제목(Info) = 큰 제목 + 회색 부제(아웃게임 제목 띠 「임무 일일 · 주간 · 업적」 방식)
var sb = Box(info, "stage_title", "Stage");
float th = N("stage_title", 4, 104f);
stageText = Fit(Txt(sb, "Title", (int)N("stage_title_font", 0, 52f), C("stage_title_font", 2, Color.white), TextAnchor.MiddleLeft, 3f), (int)N("stage_title_font", 0, 52f), (int)N("stage_title_font", 4, 40f));
stageText.rectTransform.offsetMin = new Vector2(0f, th * 0.5f - 34f);
stageText.rectTransform.offsetMax = new Vector2(0f, -(th * 0.5f - 34f)); // 높이 68 = 한 줄(넘치면 줄바꿈 대신 줄임)
stageSub = Fit(Txt(sb, "Sub", (int)N("stage_title_font", 1, 30f), C("stage_title_font", 3, new Color(0.79f, 0.76f, 0.84f)), TextAnchor.MiddleLeft, 1.5f), (int)N("stage_title_font", 1, 30f), (int)N("stage_title_font", 5, 22f));
stageSub.rectTransform.offsetMin = new Vector2(0f, th * 0.5f - 24f);
stageSub.rectTransform.offsetMax = new Vector2(0f, -(th * 0.5f - 16f)); // 한 줄 · 제목보다 조금 아래(아웃게임 부제와 같음)
// 수 칩 = 판(정적) + 아이콘 · 숫자(Info)
allyCount = CountChip("count_ally", 2);
enemyCount = CountChip("count_enemy", 3);
// 턴 현판(Info · 아군 남색 · 적 붉은색 · 금 구름 귀 안쪽 글자)
turnAllySprite = UISkin.Icon(S("turn_plaque_art", 0));
turnEnemySprite = UISkin.Icon(S("turn_plaque_art", 1));
var tp = Box(info, "turn_plaque", "TurnPlaque");
PivotCenter(tp);
turnPlaque = Art(tp, S("turn_plaque_art", 0), N("turn_plaque_art", 2, 1f), Color.white);
float pad = N("turn_plaque_art", 4, 60f);
turnText = Txt(tp, "Turn", (int)N("turn_plaque_art", 3, 46f), Color.white, TextAnchor.MiddleCenter, 4f);
turnText.rectTransform.offsetMin = new Vector2(pad, 4f);
turnText.rectTransform.offsetMax = new Vector2(-pad, 0f);
Fit(turnText, (int)N("turn_plaque_art", 3, 46f), 28);
// 안내 한 줄 · 스킬 발동 한 줄(Info · 몇 초만 · 미니맵 왼쪽까지)
var tr = Box(info, "msg_toast", "MsgToast");
toast = OutGame.UiKit.Skin(tr, S("msg_toast_art", 0, "chip"), C("msg_toast_art", 1, Color.black));
toastText = Fit(Txt(tr, "Message", (int)N("msg_toast_art", 2, 28f), Color.white, TextAnchor.MiddleCenter, 2.5f), (int)N("msg_toast_art", 2, 28f), (int)N("msg_toast_art", 3, 20f));
toastText.rectTransform.offsetMin = new Vector2(24f, 4f);
toastText.rectTransform.offsetMax = new Vector2(-24f, -4f);
toast.gameObject.SetActive(false);
var lr = Box(info, "skill_log", "SkillLog");
logChip = OutGame.UiKit.Skin(lr, S("skill_log_art", 0, "chip"), C("skill_log_art", 1, Color.black));
skillLog = Txt(lr, "Text", (int)N("skill_log_art", 2, 26f), C("skill_log_art", 3, new Color(0.6f, 1f, 0.85f)), TextAnchor.MiddleLeft, 2f);
skillLog.rectTransform.offsetMin = new Vector2(24f, 4f);
skillLog.rectTransform.offsetMax = new Vector2(-24f, -4f);
skillLog.verticalOverflow = VerticalWrapMode.Overflow;
logChip.gameObject.SetActive(false);
}
/// 수 칩 = 아웃게임 재화 칩 방식(알약 판 = 정적 · 큰 아이콘이 알약 왼쪽 밖으로 · 숫자 = Info · PD 2026-11-21 2차).
Text CountChip(string key, int iconCol)
{
var plate = Box(transform, key, key == "count_ally" ? "AllyChip" : "EnemyChip");
OutGame.UiKit.Skin(plate, S("count_art", 0, "pill"), C("count_art", 1, Color.black));
var cell = Box(info, key, plate.name + "Info");
float isz = N("count_art", 4, 70f);
float ix = N("count_art", 6, -34f);
var ic = OutGame.UiKit.Icon(cell, S("count_art", iconCol), new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(ix, 2f), isz);
if (ic != null) OutGame.UiKit.DropShadow(ic, 3f);
var t = Txt(cell, "Num", (int)N("count_art", 5, 38f), Color.white, TextAnchor.MiddleCenter, 3f);
t.rectTransform.offsetMin = new Vector2(ix + isz, 2f);
t.rectTransform.offsetMax = new Vector2(-10f, 0f);
t.horizontalOverflow = HorizontalWrapMode.Overflow;
return t;
}
string shownTitle;
string shownSub;
/// 큰 제목 + 회색 부제(부제 x = 제목 실제 폭 + 간격 · 바뀔 때만 다시 놓음).
void SetStageTitle(string title, string sub)
{
if (title == shownTitle && sub == shownSub) return;
shownTitle = title;
shownSub = sub;
stageText.text = title;
var box = (RectTransform)stageText.transform.parent;
float bw = box.rect.width > 1f ? box.rect.width : N("stage_title", 3, 500f);
float tw = Mathf.Min(stageText.preferredWidth, bw);
float x = tw + N("stage_title_font", 6, 18f);
stageSub.text = sub;
stageSub.rectTransform.offsetMin = new Vector2(x, stageSub.rectTransform.offsetMin.y);
Show(stageSub, sub.Length > 0 && x < bw - 60f);
}
void BuildMinimap()
{
// 미니맵(전장 비율 · 탭하면 그 지점으로 카메라 이동) — 지도 = Minimap(누름 칸) · 금 테 = MinimapFrame(위 · 가운데 뚫림)
Vector2 bs = battle.Config.boardSize;
float pad = N("minimap_art", 2, 8f);
float fw = N("minimap", 3, 196f);
float mmW = fw - pad * 2f;
float mmH = mmW * bs.y / Mathf.Max(0.01f, bs.x);
float x = N("minimap", 1, 868f), y = N("minimap", 2, 112f);
string anchor = S("minimap", 0, "TR");
var mrt = new GameObject("Minimap", typeof(RectTransform)).GetComponent();
mrt.SetParent(transform, false);
Place(mrt, anchor, x + pad, y + pad, mmW, mmH);
minimapBg = mrt.gameObject.AddComponent();
minimapBg.color = C("minimap_art", 3, new Color(0.08f, 0.11f, 0.2f, 0.85f));
minimapBg.raycastTarget = false;
var mid = OutGame.UiKit.Rect("Mid", mrt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(mmW, 2f));
var midImg = mid.gameObject.AddComponent();
midImg.color = C("minimap_view", 3, new Color(1f, 1f, 1f, 0.18f));
midImg.raycastTarget = false;
// 시야 사각형 · 유닛 점만 담는 Frame 층(카메라·유닛이 움직일 때마다 이 층만 다시 묶음)
minimapLive = UiLayer.Group("MinimapLive", mrt, UiRate.Frame, false);
var view = OutGame.UiKit.Rect("View", minimapLive, Vector2.zero, Vector2.zero, Vector2.zero, new Vector2(40f, 60f));
minimapView = view.gameObject.AddComponent();
minimapView.color = C("minimap_view", 0, new Color(1f, 1f, 1f, 0.2f)); // 시야 = 남색 계열 밝은 반투명 + 밝은 테(QA r1 F3 · 회색 디버그 판 반려)
minimapView.raycastTarget = false;
float vw = N("minimap_view", 2, 0f);
if (vw > 0f)
{
var vo = view.gameObject.AddComponent();
vo.effectDistance = new Vector2(vw, -vw);
vo.effectColor = C("minimap_view", 1, Color.white);
vo.useGraphicAlpha = false;
}
var frt = new GameObject("MinimapFrame", typeof(RectTransform)).GetComponent();
frt.SetParent(transform, false);
Place(frt, anchor, x, y, fw, mmH + pad * 2f);
Art(frt, S("minimap_art", 0, "bt_minimap_frame"), N("minimap_art", 1, 1f), Color.white);
}
void BuildDesk()
{
// 지휘 탁자(Info · 선택 영웅 · 아군 턴 = 높은 판 / 선택 없음 · 적 턴 = 낮은 띠) — 판 바탕은 누르지 않음(슬링샷 당기기를 막지 않게)
desk = Box(info, "desk", "Desk");
deskFullH = N("desk", 4, 280f);
deskLowH = N("desk_low", 4, 120f);
desk.sizeDelta = new Vector2(desk.sizeDelta.x, deskLowH);
// 판 = 남색 옻칠 + 위 금 테 + 양 끝 금 구름 귀(턴 현판과 한 벌 · PD 2026-11-21 3차 「영웅 정보 UI 가 디자인이 없음」) · 그림이 없으면 예전 탭 바 판
var bg = OutGame.UiKit.Fill("Bg", desk);
string da = S("desk_art", 0, "tabbar");
if (UISkin.Icon(da) != null) Art(bg, da, N("desk_art", 1, 1f), Color.white);
else OutGame.UiKit.Skin(bg, "tabbar", UISkin.Col("chrome_tab", OutGame.UiKit.BarColor));
// 면 무늬 = 톤온톤 구름(면 색 ×0.86 · 선 ×0.74 · 정보 뒤 · R37 8차 방식)
var pat = S("desk_pattern", 0);
var psp = pat.Length > 0 ? UISkin.Icon(pat) : null;
if (psp != null)
{
var pr = OutGame.UiKit.Fill("Pattern", desk, N("desk_pattern", 2, 30f), N("desk_pattern", 4, 30f), N("desk_pattern", 3, 60f), N("desk_pattern", 5, 0f));
var pimg = pr.gameObject.AddComponent();
pimg.sprite = psp;
pimg.type = Image.Type.Tiled;
pimg.pixelsPerUnitMultiplier = Mathf.Max(0.01f, N("desk_pattern", 6, 1f));
pimg.color = C("desk_pattern", 1, new Color(0.13f, 0.2f, 0.42f));
pimg.raycastTarget = false;
}
PaperText(true); // 탁자 위 글자 = 종이 위 먹 글자(표 desk_text · 없으면 예전 흰 글자)
var hintBox = Box(desk, "desk_low", "Hint");
deskHint = Txt(hintBox, "Text", (int)N("desk_hint_font", 0, 32f), C("desk_hint_font", 1, new Color(0.78f, 0.8f, 0.84f)), TextAnchor.MiddleCenter, 2.5f);
// 내용 = 높은 판 크기 고정(아래 붙음 · 판 높이 연출과 무관)
deskBody = Box(desk, "desk", "Body");
// 왼쪽 정보 묶음(초상 · 이름 · 체력 · 능력치 · 패시브) = 한 덩어리 · 위왼쪽 기준 · 좁은 화면(캔버스 폭 978)에서만 같은 비율로 줄여 오른쪽 스킬 열과 안 겹침
// (PD 2026-11-21 「액티브 스킬과 정보 사이 여백이 너무 많이 남음 → 능력치 · 패시브를 키워 여백을 좁혀」 · 표 left_col = 오른쪽 스킬 열 폭|간격|왼쪽 묶음 오른끝(1080 기준))
leftCol = OutGame.UiKit.Fill("LeftCol", deskBody);
leftCol.pivot = new Vector2(0f, 1f);
if (N("left_col", 2, 0f) > 0f)
{
var fit = leftCol.gameObject.AddComponent(); // 크기 바뀜 알림에서 배율(캡처처럼 화면 크기를 바꾼 그 프레임에도 맞음)
fit.reserveRight = N("left_col", 0, 0f);
fit.gap = N("left_col", 1, 0f);
fit.designWidth = N("left_col", 2, 0f);
}
// 초상 = 진영 색 원 바탕 → 초상(원 가림) → 금 고리 + 위 금 구름 틀(스킬 틀과 한 벌)
var ring = Box(leftCol, "portrait_ring", "Ring");
float hcx = N("portrait_hole", 0, 80f), hcy = N("portrait_hole", 1, 91f), hr = N("portrait_hole", 2, 57f);
var back = OutGame.UiKit.Rect("Back", ring, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(hcx, -hcy), new Vector2(hr * 2f, hr * 2f));
portraitBack = back.gameObject.AddComponent();
portraitBack.sprite = OutGame.UiKit.Circle;
portraitBack.raycastTarget = false;
float md = hr * 2f - N("portrait_art", 1, 4f);
var mask = OutGame.UiKit.Rect("Mask", ring, new Vector2(0f, 1f), new Vector2(0.5f, 0.5f), new Vector2(hcx, -hcy), new Vector2(md, md));
var mimg = mask.gameObject.AddComponent();
mimg.sprite = OutGame.UiKit.Circle;
mimg.raycastTarget = false;
mask.gameObject.AddComponent().showMaskGraphic = false;
float az = N("portrait_art", 2, 192f);
var art = OutGame.UiKit.Rect("Art", mask, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, N("portrait_art", 3, -33f)), new Vector2(az, az));
portraitArt = art.gameObject.AddComponent();
portraitArt.preserveAspect = true;
portraitArt.raycastTarget = false;
portraitRing = Art(OutGame.UiKit.Fill("Frame", ring), S("portrait_art", 0, "bt_portrait_ring"), 1f, Color.white);
portraitRing.preserveAspect = false;
// 이름 = 붉은 옻칠 명패(보물 · 성장 화면 명패와 같은 그림) 위 병종 아이콘 + 이름
if (S("name_plate_art", 0).Length > 0) // 비움 = 명패 없이 종이 위 이름(1안)
Art(Box(leftCol, "name_plate", "NamePlate"), S("name_plate_art", 0), N("name_plate_art", 1, 1.5f), Color.white);
var tbox = Box(leftCol, "type_icon", "Type");
typeIcon = OutGame.UiKit.Icon(tbox, OutGame.UiKit.TypeSymbolId(UnitType.Infantry), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, N("type_icon", 3, 48f));
if (typeIcon != null && S("type_icon_art", 0).Length == 0) OutGame.UiKit.DropShadow(typeIcon, 2f); // 색 원판(B안)은 그림자 없음
// 공격 유형 줄(PD 2026-11-21 「병종 아이콘을 하트 하단으로 · 보병 = 공격 유형 : 반사 · 기병 = 관통 · 창병 = 밀기 · 궁병 = 발사 · 책사 = 폭파 · 아이콘화」)
// 표 atk_type_label · atk_type_icon · atk_type_value = 자리 · atk_type_art = 아이콘 앞붙이(+ 병종 소문자)|라벨 색|값 색|글자
if (L("atk_type_label").Length > 0)
{
int af = (int)N("atk_type_art", 3, 24f);
var al = Txt(Box(leftCol, "atk_type_label", "AtkTypeLabel"), "Text", af, C("atk_type_art", 1, deskInk), TextAnchor.MiddleLeft, 2f);
al.horizontalOverflow = HorizontalWrapMode.Overflow;
al.text = T("battle.atk_type.label");
var aib = Box(leftCol, "atk_type_icon", "AtkTypeIcon");
atkTypeIcon = aib.gameObject.AddComponent();
atkTypeIcon.preserveAspect = true;
atkTypeIcon.raycastTarget = false;
atkTypeText = Txt(Box(leftCol, "atk_type_value", "AtkTypeValue"), "Text", af, C("atk_type_art", 2, deskInk), TextAnchor.MiddleLeft, 2f);
atkTypeText.horizontalOverflow = HorizontalWrapMode.Overflow;
}
nameText = Fit(Txt(Box(leftCol, "hero_name", "Name"), "Text", (int)N("hero_name_font", 0, 44f), deskInk, TextAnchor.MiddleLeft, 4f), (int)N("hero_name_font", 0, 44f), 24);
var sc = Box(leftCol, "side_chip", "Side");
sideChip = UISkin.Icon(S("side_chip_art", 0, "chip")) != null
? Art(sc, S("side_chip_art", 0), N("side_chip_art", 5, 1f), C("side_chip_art", 1, Color.blue)) // 진영 목패(로비 이름 받침과 같은 tre_tag · 색만 진영)
: OutGame.UiKit.Skin(sc, S("side_chip_art", 0, "chip"), C("side_chip_art", 1, Color.blue));
float keepCap = strokeCap;
if (N("side_chip_art", 6, -1f) >= 0f) strokeCap = N("side_chip_art", 6, 0f); // 도장 글자 테(0 = 없음 · 흰 글자에 크림 테 = 「아군」 뭉개짐 · 검토 r4)
sideText = Fit(Txt(sc, "Text", (int)N("side_chip_art", 4, 26f), Color.white, TextAnchor.MiddleCenter, 2f), (int)N("side_chip_art", 4, 26f), 18);
strokeCap = keepCap;
sideText.rectTransform.offsetMin = new Vector2(8f, 2f);
sideText.rectTransform.offsetMax = new Vector2(-8f, 0f);
// 능력치 판(PD 2026-11-21 「공격력 · 방어력 · 사정거리 정보와 패시브 정보를 백판 색깔로 구분하는 프레임」 · 표 stat_panel + stat_panel_art = 그림|9 분할 배율 · 알약보다 먼저 = 뒤)
if (S("stat_panel_art", 0).Length > 0 && UISkin.Icon(S("stat_panel_art", 0)) != null)
Art(Box(leftCol, "stat_panel", "StatPanel"), S("stat_panel_art", 0), N("stat_panel_art", 1, 2f), Color.white);
// 초상 아래 성급(PD 「영웅 초상화 아래는 영웅의 성급」 · 표 star_row = 자리 · star_art = 별 그림|크기|간격|최대 개수)
if (L("star_row").Length > 0)
{
starRow = Box(leftCol, "star_row", "Stars");
int smax = (int)N("star_art", 3, 7f);
for (int i = 0; i < smax; i++)
{
var si = OutGame.UiKit.At(starRow, "Star" + i, 0f, 0f, N("star_art", 1, 26f), N("star_art", 1, 26f)).gameObject.AddComponent();
si.sprite = UISkin.Icon(S("star_art", 0, "star_on"));
si.preserveAspect = true;
si.raycastTarget = false;
stars.Add(si);
}
}
var hb = Box(leftCol, "hp_bar", "Hp");
// 체력 바 바탕 = 표 hp_bar_art(그림 | 9 분할 배율 | 채움 안쪽 여백 · B안 어두운 알약) · 없으면 팩 hp_bg
float hin = N("hp_bar_art", 2, 4f);
if (S("hp_bar_art", 0).Length > 0 && UISkin.Icon(S("hp_bar_art", 0)) != null) Art(hb, S("hp_bar_art", 0), N("hp_bar_art", 1, 1f), Color.white);
else OutGame.UiKit.Skin(hb, "hp_bg", UISkin.Col("hp_bg", Color.white));
hpFillW = N("hp_bar", 3, 340f) - hin * 2f;
hpFill = OutGame.UiKit.At(hb, "Fill", hin, hin, hpFillW, N("hp_bar", 4, 34f) - hin * 2f);
// 채움 = 표 hp_bar_art 칸 4(흰 바탕 둥근 채움 그림 · 체력 색을 곱함 · 팩 hp_fill 은 자체 테가 있어 어두운 알약 안에서 오른끝이 깨져 보임 · PD 2026-11-21)
string hfa = S("hp_bar_art", 3);
if (hfa.Length > 0 && UISkin.Icon(hfa) != null) hpFillImg = Art(hpFill, hfa, N("hp_bar_art", 1, 1f), UISkin.Col("hp_hi", Color.green));
else hpFillImg = OutGame.UiKit.Skin(hpFill, "hp_fill", UISkin.Col("hp_hi", Color.green));
hpFillMin = hfa.Length > 0 ? N("hp_bar", 4, 34f) - hin * 2f : 12f; // 둥근 끝이 찌그러지지 않는 최소 폭
// 체력 숫자 = 표 hp_text_art(가운데 C | 글자 색 | 테 색 | 테 두께 · B안 = 바 안 흰 글자) · 없으면 바 밖 먹 글자
if (L("hp_text_art").Length > 0)
{
var kc = strokeCol; float kp = strokeCap;
strokeCol = C("hp_text_art", 2, new Color(0.23f, 0.16f, 0.13f)); strokeCap = N("hp_text_art", 3, 2f);
hpText = Txt(Box(leftCol, "hp_text", "HpText"), "Text", (int)N("stat_font", 0, 32f), C("hp_text_art", 1, Color.white),
S("hp_text_art", 0, "L") == "C" ? TextAnchor.MiddleCenter : TextAnchor.MiddleLeft, 3f);
strokeCol = kc; strokeCap = kp;
}
else hpText = Txt(Box(leftCol, "hp_text", "HpText"), "Text", (int)N("stat_font", 0, 32f), deskInk, TextAnchor.MiddleLeft, 3f);
hpText.horizontalOverflow = HorizontalWrapMode.Overflow;
// 생명력 하트(PD 「하트 형태의 아이콘과 함께 수치가 게이지 형태로」 · 표 hp_icon = 자리 · hp_icon_art = 그림 · 바 왼끝에 걸침 = 바 다음에 그림)
if (S("hp_icon_art", 0).Length > 0 && UISkin.Icon(S("hp_icon_art", 0)) != null)
{
var hi = Art(Box(leftCol, "hp_icon", "HpIcon"), S("hp_icon_art", 0), 1f, Color.white);
hi.preserveAspect = true;
}
Image dummy;
atkText = StatChip("stat_atk", "Atk", S("stat_icon_art", 0, "sword"), (int)N("stat_font", 0, 32f), out dummy);
defText = StatChip("stat_def", "Def", S("stat_icon_art", 1, "shield"), (int)N("stat_font", 0, 32f), out dummy);
extraText = StatChip("stat_extra", "Extra", S("stat_icon_art", 2), (int)N("stat_font", 1, 26f), out extraIcon);
if (statLabels.Count == 3)
{
statLabels[0].text = T("battle.stat.atk_l");
statLabels[1].text = T("battle.stat.def_l");
}
// 패시브 묶음(패시브가 있을 때만) = 움푹한 목패 받침 + 금 틀 아이콘 + 붉은 「패시브」 목패 + 금 이름 + 설명(PD 2026-11-21 2 · 3차)
passiveGroup = Box(leftCol, "desk", "PassiveGroup");
if (L("desk_rule").Length > 0) // 먹선 한 줄(능력치 ↔ 패시브 나눔 · 패시브 묶음 안 = 패시브 없는 유닛(적 병사)에서 화면 아래끝에 홀로 남던 선 없앰 · 검토 r4)
{
var rl = Box(passiveGroup, "desk_rule", "Rule").gameObject.AddComponent();
rl.color = C("desk_rule_color", 0, new Color(0.6f, 0.48f, 0.33f));
rl.raycastTarget = false;
}
if (S("passive_tray_art", 0).Length > 0) // 비움 = 받침 없음(1안 = 먹선 한 줄로 나눔)
Art(Box(passiveGroup, "passive_tray", "Tray"), S("passive_tray_art", 0), N("passive_tray_art", 2, 0.6f), C("passive_tray_art", 1, new Color(0.08f, 0.1f, 0.2f)));
var pib = Box(passiveGroup, "passive_icon", "PassiveIcon");
passiveIcon = pib.gameObject.AddComponent();
passiveIcon.preserveAspect = true;
passiveIcon.raycastTarget = false;
float pf = N("passive_icon_frame", 1, 6f);
if (S("passive_icon_frame", 0).Length > 0)
Art(OutGame.UiKit.Fill("Frame", pib, -pf, -pf, -pf, -pf - N("passive_icon_frame", 3, 0f)), S("passive_icon_frame", 0), N("passive_icon_frame", 2, 1.5f), Color.white); // 칸 4 = 아래 입술(B안 타일)
var lab = Box(passiveGroup, "passive_label", "Label");
Art(lab, S("passive_label_art", 0, "tre_tag"), N("passive_label_art", 2, 1.3f), C("passive_label_art", 1, new Color(0.72f, 0.21f, 0.16f)));
float keepCap2 = strokeCap;
if (N("passive_label_art", 4, -1f) >= 0f) strokeCap = N("passive_label_art", 4, 0f); // 도장 글자 테(0 = 없음)
var lt = Fit(Txt(lab, "Text", (int)N("passive_label_art", 3, 20f), Color.white, TextAnchor.MiddleCenter, 2f), (int)N("passive_label_art", 3, 20f), 14);
strokeCap = keepCap2;
lt.rectTransform.offsetMin = new Vector2(8f, 2f);
lt.rectTransform.offsetMax = new Vector2(-8f, 0f);
lt.text = T("battle.passive.label");
passiveLine = Box(passiveGroup, "passive_line", "Passive");
skillPassive = Fit(Txt(passiveLine, "Text", (int)N("passive_font", 0, 28f), C("passive_font", 1, new Color(1f, 0.88f, 0.54f)), TextAnchor.MiddleLeft, 2.5f), (int)N("passive_font", 0, 28f), 18);
// 패시브 설명(PD 2026-11-21 2차 「패시브 설명이 보여지도록」 · 넘치면 글자 줄임)
passiveDesc = Fit(Txt(Box(passiveGroup, "passive_desc", "PassiveDesc"), "Text", (int)N("passive_desc_font", 0, 22f), C("passive_desc_font", 2, new Color(1f, 0.95f, 0.84f)), TextAnchor.UpperLeft, 1.5f),
(int)N("passive_desc_font", 0, 22f), (int)N("passive_desc_font", 1, 16f));
passiveDesc.lineSpacing = N("passive_desc_font", 3, 1.1f);
deskBody.gameObject.SetActive(false);
PaperText(false);
}
/// 표 stat_chip_art 칸 3 = 맞춤 알약 뒷붙이 — 알약 왼끝을 그 아이콘 실루엣 밑에서 끝나게 깎은 그림(아이콘 이름 + 뒷붙이 · 아트 pill_fit.py · PD 2026-11-22 「튀어나온 부분」) · 그림이 없으면 칸 0 그림.
void ChipFit(Image chip, string iconId)
{
if (chip == null) return;
string suf = S("stat_chip_art", 3);
var sp = suf.Length > 0 && !string.IsNullOrEmpty(iconId) ? UISkin.Icon(iconId + suf) : null;
if (sp == null) sp = UISkin.Icon(S("stat_chip_art", 0));
if (sp != null && chip.sprite != sp) chip.sprite = sp;
}
Text StatChip(string key, string name, string icon, int size, out Image iconImg)
{
var rt = Box(leftCol, key, name);
iconImg = null;
// 칩 = 종이 쪽지(표 stat_chip_art = 그림 | 틴트 | 9 분할 배율 · 1안) · 줄은 있는데 그림 칸이 비면 바탕 없음(종이에 아이콘 + 숫자 · 검토 r4) · 줄이 없으면 어두운 알약
bool bare = L("stat_chip_art").Length > 0 && S("stat_chip_art", 0).Length == 0;
Image chipImg = null;
if (!bare && S("stat_chip_art", 0).Length > 0 && UISkin.Icon(S("stat_chip_art", 0)) != null)
chipImg = Art(rt, S("stat_chip_art", 0), N("stat_chip_art", 2, 1f), C("stat_chip_art", 1, Color.white));
else if (!bare) OutGame.UiKit.Skin(rt, "chip", UISkin.Col("chip_dark", new Color(0.12f, 0.12f, 0.16f, 0.92f)));
ChipFit(chipImg, icon);
if (key == "stat_extra") extraChip = chipImg;
float h = N(key, 4, 56f);
// 아이콘 = 표 stat_icon_art(공격 | 방어 | 슬링 | 크기 | 숫자와 간격 | 그림자 0/1) · 줄이 없으면 예전 팩 아이콘 + 그림자
bool tableIcon = L("stat_icon_art").Length > 0;
float isz = tableIcon ? N("stat_icon_art", 3, 44f) : Mathf.Min(h, 44f);
float gap = tableIcon ? N("stat_icon_art", 4, 8f) : 4f;
float ix = bare ? isz * 0.5f : h * 0.5f + 2f;
float lx = bare ? 0f : 16f;
if (!string.IsNullOrEmpty(icon))
{
var ic = OutGame.UiKit.Icon(rt, icon, new Vector2(0f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(ix, 0f), isz);
if (ic != null)
{
if (!tableIcon || N("stat_icon_art", 5, 0f) > 0.5f) OutGame.UiKit.DropShadow(ic, 2f);
lx = (bare ? isz : h) + gap;
iconImg = ic;
}
}
if (L("stat_label").Length > 0)
{
// B안 알약(PD 2026-11-21 「스텟 설명은 B안」) = 아이콘이 알약 왼쪽 밖으로 걸침 · 작은 금빛 이름 · 오른쪽 흰 숫자
// 표 stat_label = 이름 글자 | 이름 색 | 숫자 색 | 아이콘 x(알약 왼끝 기준 가운데) | 숫자 오른쪽 여백 | 글자 테 두께
if (iconImg != null) iconImg.rectTransform.anchoredPosition = new Vector2(N("stat_label", 3, 20f), 0f);
float kp = strokeCap; strokeCap = N("stat_label", 5, 0f);
var lab = Txt(rt, "Label", (int)N("stat_label", 0, 22f), C("stat_label", 1, new Color(0.93f, 0.78f, 0.47f)), TextAnchor.MiddleLeft, 2f);
lab.rectTransform.offsetMin = new Vector2(lx, 2f);
lab.horizontalOverflow = HorizontalWrapMode.Overflow;
var val = Txt(rt, "Text", size, C("stat_label", 2, Color.white), TextAnchor.MiddleRight, 3f);
val.rectTransform.offsetMax = new Vector2(-N("stat_label", 4, 14f), 0f);
val.horizontalOverflow = HorizontalWrapMode.Overflow;
strokeCap = kp;
statLabels.Add(lab);
return val;
}
var t = Txt(rt, "Text", size, deskInk, lx > 16f || bare ? TextAnchor.MiddleLeft : TextAnchor.MiddleCenter, 3f);
t.rectTransform.offsetMin = new Vector2(lx, 2f);
t.rectTransform.offsetMax = new Vector2(bare ? 0f : -12f, 0f);
return Fit(t, size, 18);
}
readonly List statLabels = new List(); // B안 능력치 이름(공격 · 방어 · 슬링/사거리/광역)
RectTransform leftCol; // 왼쪽 정보 묶음(좁은 화면 비율 축소 = UiFitScale)
Image atkTypeIcon; // 공격 유형 아이콘(반사 · 관통 · 밀기 · 발사 · 폭파)
Text atkTypeText;
Text skillBubbleText; // 예약 · 대기 말풍선 글자(즉시 시전 / 공격 시 발동)
RectTransform starRow; // 초상 아래 성급
readonly List stars = new List();
Image skillFx; // 예약 · 대기 = 외곽선 셰이더 테 강조(Icon/Outline Shader UI Friendly)
Image skillNamePlate; // 스킬 이름 장식판
bool skillBtnMode; // B안 스킬 단추(표 skill_btn_art 있음)
Image skillArmedFrame, skillRibbon, skillChevron; // B안 즉시 시전 대기 안내
/// 표 칸 = 그림|x|y|w|h(화면 좌표) → 스킬 단추(rt · 왼쪽 위 sx, sy) 안 그림 · 처음엔 숨김 · 그림 없으면 null.
Image ArtAt(RectTransform rt, string name, string key, float sx, float sy)
{
string id = S(key, 0);
if (id.Length == 0 || UISkin.Icon(id) == null) return null;
var r = OutGame.UiKit.At(rt, name, N(key, 1, 0f) - sx, N(key, 2, 0f) - sy, N(key, 3, 100f), N(key, 4, 50f));
var img = Art(r, id, N(key, 8, 2f), Color.white);
img.preserveAspect = false;
r.gameObject.SetActive(false);
return img;
}
Image extraIcon; // 셋째 능력치 아이콘(슬링 = 표 그림 · 사거리 · 광역 = 병종 기호)
Image extraChip; // 셋째 능력치 알약 바탕(아이콘이 바뀌면 맞춤 알약도 바꿈)
float skillTagTrH = 42f; // 이름표 아래 줄(발동 방식) 높이
void BuildSkill()
{
// 스킬 버튼(영웅을 터치하면 솟음 · 탭 = 예약/취소 · 즉시 발동 · 아이콘과 글자 겹침 0 = 이름 · 상태는 틀 밖)
float sx = N("skill_socket", 1, 824f), sy = N("skill_socket", 2, 1568f);
// 번짐(틀 뒤 · 사용 가능 = 숨쉬기 · 예약 · 한 번 더 터치 대기 = 고정 밝음) = 틀 실루엣 두 겹 금빛 — 방사형 빛줄기 아님(PD 금지)
skillGlow = Glow("SkillGlow", true);
skillGlowOn = Glow("SkillGlowOn", false);
var rt = Box(info, "skill_socket", "SkillButton");
PivotCenter(rt);
skillPanel = Art(rt, S("skill_socket_art", 0, "bt_skill_socket"), N("skill_socket_art", 2, 1f), Color.white); // 칸 3 = 9 분할 배율(B안 2배 그림 = 2)
skillPanel.preserveAspect = false;
var ib = OutGame.UiKit.At(rt, "Icon", N("skill_icon", 0, 40f), N("skill_icon", 1, 62f), N("skill_icon", 2, 152f), N("skill_icon", 3, 152f));
skillIcon = ib.gameObject.AddComponent();
skillIcon.preserveAspect = true;
skillIcon.raycastTarget = false;
// 위 덮개(표 skill_socket_art 둘째 칸 = 안 바닥이 투명한 같은 틀) = 아이콘을 바닥보다 조금 크게 깔고 둥근 귀를 틀이 가림(QA r4 B4 「직각 아이콘 네 귀에 틈」)
string topId = S("skill_socket_art", 1);
if (topId.Length > 0 && UISkin.Icon(topId) != null)
{
var top = Art(OutGame.UiKit.Fill("FrameTop", rt), topId, N("skill_socket_art", 2, 1f), Color.white);
top.preserveAspect = false;
}
skillCool = Txt(ib, "Cool", (int)N("skill_cool_font", 0, 96f), Color.white, TextAnchor.MiddleCenter, 5f);
skillCool.verticalOverflow = VerticalWrapMode.Overflow;
skillCool.rectTransform.offsetMin = new Vector2(0f, 24f);
skillCoolUnit = Txt(ib, "Unit", (int)N("skill_cool_font", 1, 30f), Color.white, TextAnchor.LowerCenter, 2.5f);
skillCoolUnit.rectTransform.offsetMin = new Vector2(0f, 10f);
// 이름표 = 틀 밖(표 좌표 → 틀 기준) · 위 줄 = 스킬 이름 + Lv(예약 · 지점 선택 · 한 번 더 터치 · 행동 완료 · 잠김 = 같은 자리에 상태) · 아래 줄 = 즉시 시전 / 행동 시 발동
// (틀 위로 뜬 상태 표는 전장 이름표를 덮어 없앰 · QA r1 F1 · 발동 방식 표시 = PD 2026-11-21 2차)
float nh = N("skill_name_tag", 4, 82f), trH = N("skill_trigger", 3, 42f);
skillTagTrH = trH;
var nt = OutGame.UiKit.At(rt, "NameTag", N("skill_name_tag", 1, 792f) - sx, N("skill_name_tag", 2, 1830f) - sy, N("skill_name_tag", 3, 272f), nh);
bool paperTag = UISkin.Icon(S("skill_state_art", 0, "chip")) != null; // 종이 쪽지 이름표(1안) · 아니면 어두운 알약
stateTag = paperTag ? Art(nt, S("skill_state_art", 0), N("skill_state_art", 4, 1f), C("skill_state_art", 1, Color.white))
: OutGame.UiKit.Skin(nt, S("skill_state_art", 0, "chip"), C("skill_state_art", 1, Color.black));
PaperText(paperTag);
skillBtnMode = L("skill_btn_art").Length > 0;
if (skillBtnMode)
{
// B안(PD 2026-11-21 「버튼 디자인 · 액티브 스킬 사용 안내는 B안」) = 이름은 타일 위 종이에 먹 글자 · 아래 = 상태별 색 큰 단추(행동 시 발동 · 즉시 시전 · 발동! · 예약됨 · 행동 완료)
// 표 skill_name_pos = x|y|w|h(화면 좌표) · skill_btn_art = 평소|대기|예약|꺼짐 그림 · skill_btn_font = 글자|대기 글자|테 색|테 두께
var kc = strokeCol; float kp = strokeCap;
// 스킬 이름 장식판(PD 「스킬 이름 부분을 장식할 UI」 · 표 skill_name_plate = 그림|9 분할 배율 · 자리 = skill_name_pos)
float npx = N("skill_name_pos", 0, 790f) - sx, npy = N("skill_name_pos", 1, 1578f) - sy, npw = N("skill_name_pos", 2, 220f), nph = N("skill_name_pos", 3, 36f);
if (S("skill_name_plate", 0).Length > 0 && UISkin.Icon(S("skill_name_plate", 0)) != null)
{
skillNamePlate = Art(OutGame.UiKit.At(rt, "NamePlate", npx, npy, npw, nph), S("skill_name_plate", 0), N("skill_name_plate", 1, 1f), Color.white);
skillNamePlate.preserveAspect = false;
}
// 이름 글자 = 표 skill_name_pos 칸 5~7(색 | 테 색 | 테 두께 · 장식판 위 흰 글자) · 없으면 종이 먹 글자
if (S("skill_name_pos", 5).Length > 0) { strokeCol = C("skill_name_pos", 5, kc); strokeCap = N("skill_name_pos", 6, 2f); }
var nmt = OutGame.UiKit.At(rt, "Name", npx, npy, npw, nph);
skillName = Fit(Txt(nmt, "Text", (int)N("skill_name_font", 0, 28f), C("skill_name_pos", 4, deskInk), TextAnchor.MiddleCenter, 3f), (int)N("skill_name_font", 0, 28f), (int)N("skill_name_font", 1, 20f));
skillName.rectTransform.offsetMin = new Vector2(N("skill_name_pos", 7, 12f), N("skill_name_pos", 8, 0f));
skillName.rectTransform.offsetMax = new Vector2(-N("skill_name_pos", 7, 12f), 0f);
strokeCol = kc; strokeCap = kp;
strokeCol = C("skill_btn_font", 2, new Color(0.23f, 0.16f, 0.13f)); strokeCap = N("skill_btn_font", 3, 2f);
skillState = Fit(Txt(nt, "State", (int)N("skill_btn_font", 0, 28f), Color.white, TextAnchor.MiddleCenter, 3f), (int)N("skill_btn_font", 1, 34f), 18);
skillState.rectTransform.offsetMin = new Vector2(12f, N("skill_btn_font", 4, 7f));
skillState.rectTransform.offsetMax = new Vector2(-12f, 0f);
strokeCol = kc; strokeCap = kp;
skillTrigger = Txt(nt, "Trigger", 20, Color.white, TextAnchor.MiddleCenter, 0f); // 표시 안 함(디버그 글 · 발동 방식은 단추 글자)
skillTrigger.enabled = false;
// 대기 안내 = 타일 노란 테 + 노란 리본 「한 번 더 터치하면」 + 꺾쇠(표 skill_armed_frame · skill_ribbon · skill_chevron = 그림|x|y|w|h 화면 좌표)
skillArmedFrame = ArtAt(rt, "ArmedFrame", "skill_armed_frame", sx, sy);
skillRibbon = ArtAt(rt, "Ribbon", "skill_ribbon", sx, sy);
skillChevron = ArtAt(rt, "Chevron", "skill_chevron", sx, sy);
// 예약 · 대기 = 틀 가장자리 흐르는 빛(PD 「스킬 발동 예약이나 선택된 상태일 경우 Icon/Outline Shader (UI Friendly) 에셋으로 프레임 가장자리를 이펙트로 강조」)
// 표 skill_fx = 재질(Resources)|x|y|w|h(타일 기준)|테 색|밝기|불투명 — 셰이더 _Time 으로 움직임(캔버스 다시 묶기 없음)
var fxm = S("skill_fx", 0).Length > 0 ? Resources.Load(S("skill_fx", 0)) : null;
if (fxm != null)
{
var fr = OutGame.UiKit.At(rt, "SelectFx", N("skill_fx", 1, -22f), N("skill_fx", 2, -22f), N("skill_fx", 3, 208f), N("skill_fx", 4, 208f));
skillFx = fr.gameObject.AddComponent();
var mi = new Material(fxm);
if (S("skill_fx", 5).Length > 0) mi.SetColor("_StrokeColor", C("skill_fx", 5, Color.yellow));
if (S("skill_fx", 6).Length > 0) mi.SetFloat("_EmissiveIntensity", N("skill_fx", 6, 1f));
if (S("skill_fx", 7).Length > 0) mi.SetFloat("_Opacity", N("skill_fx", 7, 1f));
// 그 밖의 셰이더 값 = 표 skill_fx_props(이름=값 | …) · PD 「강조 연출이 과하지 않게 · 화풍 고려」 = 마스크 세기 · 노이즈 · 속도로 조절
foreach (var kvs in L("skill_fx_props"))
{
int eq = kvs.IndexOf('=');
float fv;
if (eq > 0 && float.TryParse(kvs.Substring(eq + 1).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out fv) && mi.HasProperty(kvs.Substring(0, eq).Trim()))
mi.SetFloat(kvs.Substring(0, eq).Trim(), fv);
}
skillFx.material = mi;
skillFx.raycastTarget = false;
fr.gameObject.SetActive(false);
}
if (skillRibbon != null)
{
// 안내 글자 = 표 skill_ribbon 칸 10 · 11(글자 색 | 테 두께 · 0 = 없음 · 말풍선 = 먹 글자) · 없으면 흰 글자 + 단추 테
strokeCol = C("skill_btn_font", 2, new Color(0.23f, 0.16f, 0.13f)); strokeCap = S("skill_ribbon", 10).Length > 0 ? N("skill_ribbon", 10, 0f) : N("skill_btn_font", 3, 2f);
var rtx = Fit(Txt(skillRibbon.rectTransform, "Text", (int)N("skill_ribbon", 5, 26f), C("skill_ribbon", 9, Color.white), TextAnchor.MiddleCenter, 3f), (int)N("skill_ribbon", 5, 26f), 18);
rtx.rectTransform.offsetMin = new Vector2(N("skill_ribbon", 6, 30f), N("skill_ribbon", 7, 16f));
rtx.rectTransform.offsetMax = new Vector2(-N("skill_ribbon", 6, 30f), -2f);
rtx.text = T("battle.skill.armed_ribbon");
skillBubbleText = rtx;
strokeCol = kc; strokeCap = kp;
}
}
else
{
skillName = Fit(Txt(nt, "Name", (int)N("skill_name_font", 0, 28f), deskInk, TextAnchor.MiddleCenter, 3f), (int)N("skill_name_font", 0, 28f), (int)N("skill_name_font", 1, 20f));
skillName.rectTransform.offsetMin = new Vector2(16f, trH - 8f);
skillName.rectTransform.offsetMax = new Vector2(-16f, -4f);
skillState = Fit(Txt(nt, "State", (int)N("skill_state_art", 3, 28f), deskInk, TextAnchor.MiddleCenter, 3f), (int)N("skill_state_art", 3, 28f), 18);
skillState.rectTransform.offsetMin = new Vector2(16f, trH - 8f);
skillState.rectTransform.offsetMax = new Vector2(-16f, -4f);
skillTrigger = Fit(Txt(nt, "Trigger", (int)N("skill_trigger", 0, 22f), Color.white, TextAnchor.MiddleCenter, 2f), (int)N("skill_trigger", 0, 22f), 16);
skillTrigger.rectTransform.offsetMin = new Vector2(16f, 8f);
skillTrigger.rectTransform.offsetMax = new Vector2(-16f, -(nh - trH));
}
PaperText(false);
skillBaseScale = rt.localScale;
rt.gameObject.SetActive(false);
}
///
/// 스킬 틀 번짐 = 틀 그림 실루엣 두 겹(안쪽 진하게 · 바깥 옅게)을 틀 뒤에 금빛으로 — 남색 탁자 위에서도 보임(QA r1 M7 · glow_circle 알파 섞기 · 덧셈 합성 둘 다 1배에서 안 보였음).
/// pulse = 숨쉬기(층 = Frame 캔버스 · 겹마다 UiPulse) · 아니면 고정 밝음.
///
RectTransform Glow(string name, bool pulse)
{
var rt = Box(info, "skill_socket", name);
if (pulse) UiLayer.Nest(rt.gameObject, UiRate.Frame, false); // 매 프레임 알파 = 이 층만 다시 묶음
var sp = UISkin.Icon(S("skill_glow", 0, "bt_skill_socket"));
var col = C("skill_glow", 1, new Color(1f, 0.82f, 0.29f, 1f));
float[] pads = { N("skill_glow", 3, 22f), N("skill_glow", 2, 8f) };
float[] alphas = { N("skill_glow", 7, 0.35f), N("skill_glow", 6, 0.85f) };
for (int i = 0; i < 2; i++)
{
var lr = OutGame.UiKit.Fill(i == 0 ? "Outer" : "Inner", rt, -pads[i], -pads[i], -pads[i], -pads[i]);
var img = lr.gameObject.AddComponent();
img.sprite = sp != null ? sp : OutGame.UiKit.Round;
img.raycastTarget = false;
img.color = new Color(col.r, col.g, col.b, col.a * alphas[i]);
if (pulse)
{
var p = lr.gameObject.AddComponent(); // 위 층이 Frame 이라 캔버스를 더 만들지 않음(UiLayer.Isolate)
p.min = N("skill_glow", 4, 0.3f);
p.period = N("skill_glow", 5, 1.2f);
}
}
rt.gameObject.SetActive(false);
return rt;
}
void BuildDesc()
{
// 스킬 설명 칸(별도 목패 · 탁자 위 · 스킬 버튼 왼쪽 · 누르지 않음)
var rt = Box(info, "desc_panel", "SkillDesc");
descPanel = Art(rt, S("desc_panel_art", 0, "bt_tag_panel"), N("desc_panel_art", 2, 1f), C("desc_panel_art", 1, new Color(0.3f, 0.2f, 0.14f)));
PaperText(N("desc_panel_art", 4, 0f) > 0.5f); // 표 칸 5 = 1 이면 종이 위 글자(작은 두루마리 · 1안)
var ib = OutGame.UiKit.At(rt, "Icon", 0f, 0f, 72f, 72f);
descIcon = ib.gameObject.AddComponent();
descIcon.preserveAspect = true;
descIcon.raycastTarget = false;
descName = Txt(OutGame.UiKit.At(rt, "Name", 0f, 0f, 100f, 46f), "Text", (int)N("desc_font", 0, 36f), C("desc_colors", 0, new Color(1f, 0.83f, 0.35f)), TextAnchor.MiddleLeft, 3f);
descName.horizontalOverflow = HorizontalWrapMode.Overflow;
descKind = Txt(OutGame.UiKit.At(rt, "Kind", 0f, 0f, 100f, 30f), "Text", (int)N("desc_font", 1, 24f), C("desc_colors", 1, new Color(0.78f, 0.8f, 0.84f)), TextAnchor.MiddleLeft, 2f);
descKind.horizontalOverflow = HorizontalWrapMode.Overflow;
var cr = OutGame.UiKit.Rect("Cool", rt, new Vector2(1f, 1f), new Vector2(1f, 1f), Vector2.zero, new Vector2(170f, 48f));
descCool = OutGame.UiKit.Skin(cr, "chip", UISkin.Col("chip_dark", Color.black));
float keepCap3 = strokeCap;
if (N("desc_cool", 5, -1f) >= 0f) strokeCap = N("desc_cool", 5, 0f); // 쿨 칩 흰 글자 테(0 = 없음 · 종이 글자 모드 크림 테 = 「쿨」 뭉개짐 · QA r4 B1)
int ccf = (int)N("desc_cool", 4, 26f);
descCoolText = Fit(Txt(cr, "Text", ccf, Color.white, TextAnchor.MiddleCenter, 2f), ccf, 18);
strokeCap = keepCap3;
descText = Txt(OutGame.UiKit.Fill("Desc", rt), "Text", (int)N("desc_font", 2, 28f), C("desc_colors", 2, new Color(1f, 0.95f, 0.84f)), TextAnchor.UpperLeft, 2f);
descText.lineSpacing = N("desc_font", 4, 1.15f);
descText.verticalOverflow = VerticalWrapMode.Overflow;
rt.gameObject.SetActive(false);
PaperText(false);
}
void BuildResult()
{
resultLayer = UiLayer.Group("Result", transform, UiRate.Event, false);
resultOverlay = OutGame.UiKit.Fill("ResultOverlay", resultLayer).gameObject;
var dim = resultOverlay.AddComponent();
dim.color = new Color(0f, 0f, 0f, 0.65f);
dim.raycastTarget = false;
var tr = OutGame.UiKit.Rect("Title", resultOverlay.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 60f), new Vector2(1000f, 160f));
resultTitle = Txt(tr, "Text", 110, Color.white, TextAnchor.MiddleCenter, 6f);
resultTitle.verticalOverflow = VerticalWrapMode.Overflow;
var sr = OutGame.UiKit.Rect("Sub", resultOverlay.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -80f), new Vector2(1000f, 120f));
resultSub = Txt(sr, "Text", 40, Color.white, TextAnchor.MiddleCenter, 3f);
resultSub.verticalOverflow = VerticalWrapMode.Overflow;
resultOverlay.SetActive(false);
}
// ---------- 공개(입력 · 시험 · 캡처) ----------
public void SetSelected(Unit u)
{
if (selected != u)
{
timedUntil = 0f;
armedUnit = null;
if (skillMsg != null && lastMsg == skillMsg) msgAt = -10f; // 다른 유닛을 고르면 전 유닛 스킬 안내 줄 닫음(QA r1 F5)
}
selected = u;
}
public bool SkillButtonVisible
{
get { return skillPanel != null && skillPanel.gameObject.activeSelf; }
}
public string SkillButtonText
{
get { return skillPanel != null ? skillName.text + " | " + skillState.text + " | " + skillTrigger.text + " | " + skillPassive.text : ""; }
}
public string SkillLogText
{
get { return skillLog != null ? skillLog.text : ""; }
}
/// 스킬 설명 칸이 떠 있는가 · 그 글(시험 · 캡처).
public string SkillDescText
{
get { return descPanel != null && descPanel.gameObject.activeSelf ? descName.text + " | " + descText.text : ""; }
}
///
/// 화면 점이 철수 · 스킬 버튼 · 패시브 줄 위면 탭 처리 후 true — 슬링샷 입력은 건너뛴다.
/// 즉시 시전 스킬 = 첫 터치는 설명 칸 + 「한 번 더 터치하면 발동」 · 두 번째 터치 = 발동 · 다른 곳 터치 = 취소(PD 2026-11-21 2차 「즉시 발동 스킬은 정보를 알기 어려움」).
///
public bool TrySkillTap(Vector2 screen)
{
if (TryRetreatTap(screen)) return true;
if (battle == null) return false;
if (SkillButtonVisible && skillUsable && (Hit(skillPanel.rectTransform, screen) || (skillBtnMode && stateTag != null && Hit(stateTag.rectTransform, screen)))) // B안 = 아래 큰 단추도 누름
{
if (armedUnit != selected && NeedsSecondTap(selected))
{
armedUnit = selected;
timedUntil = 0f;
var s = battle.Skills.Of(selected);
string m = F("battle.skill.armed_msg", s.Active.NameKo);
battle.LastMessage = m;
skillMsg = m;
hideSkillMsg = false;
return true;
}
armedUnit = null;
PressSkill();
return true;
}
if (armedUnit != null) armedUnit = null; // 다른 곳 터치 = 취소
if (skillPassive != null && skillPassive.text.Length > 0 && Hit(passiveLine, screen))
{
ShowTimed(DescKind.Passive);
return true;
}
return false;
}
/// 두 번 터치로 발동할 스킬인가 — 즉시 시전 · 지금 쓸 수 있음(쿨 · 행동 완료 · 잠김이면 첫 터치 = 설명만).
bool NeedsSecondTap(Unit u)
{
var sys = battle != null ? battle.Skills : null;
var s = sys != null && u != null ? sys.Of(u) : null;
if (s == null || s.Active == null || s.Active.Trigger != SkillTrigger.Instant) return false;
if (sys.StateOf(u) != SkillSystem.ActiveState.Ready) return false;
return ModeBattleRules.Current == null || ModeBattleRules.Current.SkillBlocked(u) == null;
}
/// 즉시 시전 스킬이 「한 번 더 터치」 대기 중인가(시험 · 캡처).
public bool SkillArmed
{
get { return armedUnit != null && armedUnit == selected; }
}
/// 스킬 버튼 누름(탭 · 테스트 · 캡처 공용) — 쓸 수 없는 때(쿨 · 행동 완료 · 잠김) = 설명 칸 몇 초.
public string PressSkill()
{
if (battle == null || battle.Skills == null || selected == null) return null;
armedUnit = null;
var before = battle.Skills.StateOf(selected);
string blocked = ModeBattleRules.Current != null ? ModeBattleRules.Current.SkillBlocked(selected) : null;
var msg = battle.Skills.TapActive(selected);
if (!string.IsNullOrEmpty(msg)) battle.LastMessage = msg;
if (selected.View != null) selected.View.Refresh();
bool open = before == SkillSystem.ActiveState.Reserved || before == SkillSystem.ActiveState.Targeting;
bool unusable = before == SkillSystem.ActiveState.Cooldown || before == SkillSystem.ActiveState.Acted || before == SkillSystem.ActiveState.BonusMove
|| before == SkillSystem.ActiveState.NotTurn || (blocked != null && !open);
if (unusable) ShowTimed(DescKind.Active);
else timedUntil = 0f;
skillMsg = msg;
hideSkillMsg = unusable;
return msg;
}
SkillDef previewDef;
/// 시험 · 캡처: 고른 스킬의 설명을 칸에 띄움(가장 긴 설명이 칸 안에 드는지 · 영웅 선택 중일 때) · 빈 값 = 해제.
public void PreviewDescForTest(string skillId)
{
previewDef = string.IsNullOrEmpty(skillId) ? null : SkillCatalog.Get(skillId);
descKey = "";
}
void ShowTimed(DescKind k)
{
timedKind = k;
timedUnit = selected;
timedUntil = Time.unscaledTime + N("desc_seconds", 0, 3f);
}
// ---------- 철수(맹장 토벌전 raid.retreat) ----------
Image retreatBtn;
void EnsureRetreat()
{
if (retreatBtn != null || info == null) return;
var rt = Box(info, "retreat_btn", "Retreat");
retreatBtn = OutGame.UiKit.Skin(rt, S("retreat_btn_art", 0, "btn_l_red"), C("retreat_btn_art", 1, OutGame.UiKit.Red));
var t = Txt(rt, "Label", (int)N("retreat_btn_art", 2, 34f), Color.white, TextAnchor.MiddleCenter, 3f);
t.rectTransform.offsetMin = new Vector2(8f, 8f);
t.text = T("battle.retreat");
retreatBtn.gameObject.SetActive(false);
}
bool RetreatVisible
{
get
{
var r = battle != null && battle.Mode != null ? battle.Mode.rules : null;
return r != null && r.CanRetreat && battle.Phase == BattlePhase.PlayerTurn;
}
}
void RefreshRetreat()
{
bool on = RetreatVisible;
if (on) EnsureRetreat();
if (retreatBtn != null) Show(retreatBtn, on);
}
/// 철수 버튼 위를 눌렀으면 철수(그때까지 준 피해가 기록으로 남는다) 후 true.
public bool TryRetreatTap(Vector2 screen)
{
if (!RetreatVisible || retreatBtn == null || !retreatBtn.gameObject.activeSelf) return false;
if (!RectTransformUtility.RectangleContainsScreenPoint(retreatBtn.rectTransform, screen, uiCam)) return false;
battle.Mode.rules.Retreat();
battle.CheckBattleEnd();
return true;
}
// ---------- 중단(왼쪽 위 중단 버튼 → 팝업 계속 / 포기 · 모든 전투 · PD 2026-11-21 「출정에서도 언제든지 포기」) ----------
GameObject giveUpPopup;
/// 중단 버튼이 보이는가 — 전투 중(시작 연출 · 연출 장면 · 결과 제외) · 모드가 막으면(CanGiveUp = false) 없음.
public bool GiveUpVisible
{
get
{
if (battle == null || ScenarioEvent.Running) return false;
var r = battle.Mode != null ? battle.Mode.rules : null;
if (r != null && !r.CanGiveUp) return false;
var p = battle.Phase;
return p == BattlePhase.PlayerTurn || p == BattlePhase.Resolving || p == BattlePhase.EnemyTurn;
}
}
/// 중단 팝업이 떠 있는가(SlingshotInput = 전장 조작 없음).
public bool GiveUpOpen
{
get { return giveUpPopup != null; }
}
void RefreshGiveUp()
{
Show(pauseBtn, GiveUpVisible);
if (giveUpPopup != null && (battle.Phase == BattlePhase.StageClear || battle.Phase == BattlePhase.Defeat)) CloseGiveUp(); // 그사이 전투가 끝남
}
/// 중단 버튼 위를 눌렀으면 팝업을 띄우고 true.
public bool TryGiveUpTap(Vector2 screen)
{
if (!GiveUpVisible || pauseBtn == null || !pauseBtn.gameObject.activeSelf || giveUpPopup != null) return false;
if (!RectTransformUtility.RectangleContainsScreenPoint(pauseBtn, screen, uiCam)) return false;
OpenGiveUp();
return true;
}
/// 중단 팝업(붉은 옻칠 머리 현판 + 목패 몸통 · 계속 / 포기) — 포기 = BattleManager.GiveUp(패배로 끝 · 결과 화면) · 팝업 자체가 확인 단계.
public void OpenGiveUp()
{
if (giveUpPopup != null) return;
var go = new GameObject("GiveUpPopup");
giveUpPopup = go;
UiLayer.Root(go, uiCam, (int)N("pause_popup", 0, 480f), 0.3f, UiLayer.Reference, UiRate.Event);
go.AddComponent();
var root = (RectTransform)go.transform;
var dim = OutGame.UiKit.Fill("Dim", root);
var dimImg = OutGame.UiKit.Paint(dim, new Color(0f, 0f, 0f, N("pause_popup", 1, 0.6f)), false, true);
dimImg.raycastTarget = true; // 뒤 누름 막기
var body = Center(dim, "pause_body", "Panel");
Art(body, S("pause_body_art", 0, "bt_tag_panel"), N("pause_body_art", 2, 1f), C("pause_body_art", 1, new Color(0.3f, 0.2f, 0.14f))).raycastTarget = true;
var head = Center(dim, "pause_head", "Head");
Art(head, S("pause_head_art", 0, "ms_plaque"), N("pause_head_art", 1, 1f), Color.white);
var ht = Txt(head, "Title", (int)N("pause_head_art", 2, 48f), Color.white, TextAnchor.MiddleCenter, 4f);
ht.rectTransform.offsetMin = new Vector2(70f, 4f);
ht.rectTransform.offsetMax = new Vector2(-70f, 0f);
ht.text = T("battle.pause.title");
var bt = Txt(Center(dim, "pause_text", "Body"), "Text", (int)N("pause_text", 4, 34f), Color.white, TextAnchor.MiddleCenter, 3f);
bt.text = T("battle.pause.body");
var sb = Txt(Center(dim, "pause_sub", "Sub"), "Text", (int)N("pause_sub", 4, 26f), C("pause_sub", 5, new Color(0.78f, 0.8f, 0.84f)), TextAnchor.MiddleCenter, 2f);
sb.text = T("battle.pause.sub");
PopupBtn(dim, "pause_giveup", "Quit", T("battle.pause.giveup"), ConfirmGiveUp);
PopupBtn(dim, "pause_continue", "Keep", T("battle.pause.continue"), CloseGiveUp);
}
void PopupBtn(Transform parent, string key, string name, string label, System.Action onClick)
{
var rt = Center(parent, key, name);
var img = OutGame.UiKit.Skin(rt, S(key, 4, "btn_l_yellow"), C(key, 5, Color.white), true);
var b = img.gameObject.AddComponent