using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
///
/// 거래 > 상점 탭(PD 2026-11-26 확정 = 2차 A-2 「카피바라 짜임 × 우리 재질」 + 3차 V2 「인트로 게시판」 판) —
/// 나무 게시판(기둥 · 들보 · 가로대) 위 밧줄 고리로 건 방문 종이 → 머리(장면 그림 + 붉은 명패 「오늘의 상점」 · 갱신까지 · 새로고침) · 바로 가기 칩(오늘의 상점 · 보옥 · 골드 · 지금 위치 = 빨강) ·
/// 카드 격자(명패 제목 · 오목한 아이콘 칸 · 이름 · 노랑 값 버튼 · 할인 = 기울인 도장 · 상자 = 확률 「?」) · 보옥 6종(첫 구매 2배 도장) · 골드 3종(하루 한도) · 결제 안내 줄.
///
public partial class TradeScreen
{
const float ShopPaperX = 56f, ShopPaperY = 58f, ShopPaperW = 968f;
const float ShopInner = 920f, ShopCardW = 296f, ShopGap = 16f;
ScrollRect shopScrollT;
Text shopTimerT;
readonly List shopChips = new List();
readonly float[] chipY = new float[3];
float shopSheetH;
/// 오늘의 상점 칸 수 · 보옥 · 골드 카드 수(테스트).
public int ShopSlotCount { get; private set; }
public int GemCardCount { get; private set; }
public int GoldCardCount { get; private set; }
void RefreshShopPage(RectTransform p)
{
float keep = shopScrollT != null ? shopScrollT.verticalNormalizedPosition : 1f;
UiKit.Clear(p);
shopChips.Clear();
var db = S.Db;
var d = S.Save;
var now = S.Now;
float pageH = OutGameRoot.BodyH - 118f;
// 게시판 + 방문 종이(3차 V2)
Panel9(p, "Board", "tr_board_frame", 4f, 0f, 1072f, pageH, C("trade_wood", "C08C64"));
var paper = Panel9(p, "Paper", "tr_board_paper", ShopPaperX, ShopPaperY, ShopPaperW, pageH - ShopPaperY - 100f, CardC);
foreach (var hx in new[] { ShopPaperX + 150f, ShopPaperX + ShopPaperW - 190f })
{
var hook = UiSprite("tr_board_hook");
if (hook == null) continue;
var hi = UiKit.At(p, "Hook", hx, ShopPaperY - 30f, 40f, 52f).gameObject.AddComponent();
hi.sprite = hook;
hi.raycastTarget = false;
}
// ② 머리 = 장면 그림 + 명패 · 갱신까지 · 새로고침
var head = UiKit.At(paper, "ShopHead", 24f, 30f, ShopInner, 220f);
UiKit.Border(PaperFill(head, CardWell), WoodLine, 2f);
var clip = UiKit.Fill("Clip", head, 3f, 3f, 3f, 3f);
clip.gameObject.AddComponent();
var bg = UISkin.Icon("bg_dom_patrol");
if (bg != null)
{
var im = UiKit.Rect("Scene", clip, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 360f), new Vector2(ShopInner, ShopInner * bg.rect.height / bg.rect.width)).gameObject.AddComponent();
im.sprite = bg;
im.raycastTarget = false;
}
Plaque(paper, "ShopTitle", TradeText.T("trade_shop_title"), 24f + (ShopInner - 380f) * 0.5f, 6f, 380f, 64f, 30);
var tchip = UiKit.At(head, "Timer", 12f, 166f, 260f, 42f);
UiKit.Border(PaperFill(tchip, CardC), InkRed, 2f);
shopTimerT = Txt(tchip, "Text", "", 20, InkRed, 0f, 0f, 260f, 42f, TextAnchor.MiddleCenter, true);
int free = TradeRules.FreeRefreshLeft(db, d, now), left = TradeRules.RefreshLeft(d), lim = TradeRules.RefreshLimit;
string rl = free > 0 ? TradeText.F("trade_refresh_free", left, lim) : TradeText.F("trade_refresh_gem", db.Economy.ShopRefreshGem, left, lim);
var rb = UiKit.SkinBtn(head, "Refresh", left > 0 ? "btn_l_yellow" : "btn_gray", UiKit.White, rl, 20, left > 0 ? UiKit.Col("text_on_yellow", UiKit.Ink) : UiKit.White,
ShopInner - 352f, 160f, 340f, 54f, () => TradeWindows.RefreshShop(Root, Refresh));
rb.interactable = left > 0 && S.TradeAvailable;
// ① 바로 가기 칩(위에 붙음)
string[] chips = { TradeText.T("trade_chip_daily"), TradeText.T("trade_chip_gem"), TradeText.T("trade_chip_gold") };
for (int i = 0; i < chips.Length; i++)
{
int k = i;
var ch = UiKit.At(paper, "Chip" + i, 24f + i * 186f, 264f, 176f, 52f);
var img = PaperFill(ch, CardC);
UiKit.Border(img, WoodLine, 2f);
img.raycastTarget = true;
ch.gameObject.AddComponent