using System.Collections.Generic; using System.Globalization; using UnityEngine; using UnityEngine.UI; namespace TKS.OutGame { /// /// 출석부 쪽(시안 mock_event_7 · mock_event_14 = build_mock_e.py screen · banner_card · board · day_cell · final_cell) — /// 위 탭 2(오픈 기념 출석부 · 일일 출석부 · 화면 폭 반씩) · 배너(글자 없는 그림 + 게임 글자: 꼬리표 · 제목 · 특별 보상 · 남은 기간) · 나무 출석판(걸이 목패 칸 · 받은 날 = 「출석」 도장 · 받을 칸 = 금빛 + 받기 · 마지막 날 = 금 큰 칸). /// public partial class EventScreen { string attEv = ""; /// 지금 보는 출석부(att7 · att14). public string AttendEvent { get { return attEv; } } string[] AttRow(string ev) { foreach (var r in tb.All("att_ev")) if (Str(r, 0) == ev) return r; return null; } /// 출석부 고르기(테스트 · 위 탭). public void ShowAttend(string ev) { attEv = ev; ShowPage(PageAttend); } void PickAttend() { var tabs = L("att_tabs"); if (attEv.Length > 0 && System.Array.IndexOf(tabs, attEv) >= 0) return; attEv = Str(tabs, 0); // 오픈 기념이 끝났으면 일일 if (!EventRules.AttActive(S.Save, attEv, S.Now) && tabs.Length > 1) attEv = Str(tabs, 1); } // ---------- 판 배치(시안 board() 그대로 · Art · Info 공용) ---------- struct AttLay { public float x0, x1, y0, y1, ix0, ix1, iy0, iy1, lx, top, cw, ch, gx, gy; public int cols, rows; } AttLay AttLayout(string[] ev) { var B = L("board"); var a = new AttLay(); a.x0 = At(B, 0); a.x1 = 1080f - At(B, 0); a.y0 = At(B, 1); a.y1 = At(B, 2) + Extra; // 긴 화면 = 판이 아래로 늘어남 float inset = At(B, 8), pad = At(B, 3), topPad = At(B, 4); a.ix0 = a.x0 + inset; a.ix1 = a.x1 - inset; a.iy0 = a.y0 + inset; a.iy1 = a.y1 - inset; int cols0 = Mathf.RoundToInt(At(ev, 7)), rows0 = Mathf.RoundToInt(At(ev, 8)); float gx0 = At(ev, 9), gy0 = At(ev, 10); float cw0 = Mathf.Floor(((a.x1 - a.x0 - 2f * inset) - 2f * pad - (cols0 - 1) * gx0) / cols0); float footH = Str(ev, 12).Length > 0 ? At(B, 5) : 0f; float availH = (a.y1 - a.y0) - 2f * inset - topPad - footH; var pq = Sp(S_("plaque")); float asp = pq != null ? pq.rect.height / pq.rect.width : 1.45f; float rowH = (availH - (rows0 - 1) * gy0) / rows0; float cw, ch; if (cw0 * asp <= rowH) { cw = cw0; ch = Mathf.Floor(cw0 * asp); } else // 목패를 세로로 최대 max_squash 만큼 눌러 칸 폭을 지킴 { ch = Mathf.Floor(rowH); cw = Mathf.Floor(Mathf.Min(cw0, rowH / (asp * (1f - At(B, 7))))); } float room = availH - rows0 * ch; float fillGy = rows0 > 1 ? Mathf.Max(gy0, Mathf.Floor(room / (rows0 - 1))) : gy0; a.cols = cols0; a.rows = rows0; a.gx = gx0; a.gy = Mathf.Min(fillGy, At(B, 6)); a.cw = cw; a.ch = ch; a.lx = a.ix0 + Mathf.Floor(((a.ix1 - a.ix0) - (cols0 * cw + (cols0 - 1) * gx0)) * 0.5f); a.top = a.iy0 + topPad; return a; } // ---------- Art(Static) ---------- void AttendArt() { PickAttend(); var ev = AttRow(attEv); if (ev == null) return; var ab = L("att_banner"); Img(art, "Banner", Sp(Str(ev, 1)), At(ab, 0), At(ab, 1), At(ab, 2), At(ab, 3), Color.white); var a = AttLayout(ev); var bc = L("board_col"); Box(art, "BoardFrame", "card", Col(bc, 0), a.x0, a.y0, a.x1 - a.x0, a.y1 - a.y0); Box(art, "BoardInner", "soft", Col(bc, 2), a.ix0, a.iy0, a.ix1 - a.ix0, a.iy1 - a.iy0); for (int k = 1; k < 9; k++) // 나무 결(세로 판자 이음) Solid(art, "Grain" + k, Col(bc, 3), a.ix0 + (a.ix1 - a.ix0) * k / 9f - 1.5f, a.iy0 + 6f, 3f, a.iy1 - a.iy0 - 12f); for (int r = 0; r < a.rows; r++) // 걸이 줄(행마다) Solid(art, "Rail" + r, Col(bc, 4), a.ix0 + 8f, a.top + r * (a.ch + a.gy) + a.ch * 0.06f, a.ix1 - a.ix0 - 16f, 10f); // 위 현판(출석부 제목) var bs = L("board_sign"); var sg = Sp(S_("sign")); float sw = At(bs, 0), sh = sg != null ? sw * sg.rect.height / sg.rect.width : sw * 0.25f; Img(art, "BoardSign", sg, 540f - sw * 0.5f, a.y0 - sh * 0.5f + At(bs, 4), sw, sh, Color.white); Lab(art, "BoardTitle", T(Str(ev, 11)), At(bs, 1), Col(bs, 2), 'm', 540f, a.y0 + At(bs, 4) + 2f, Col(bs, 3), 3f); if (Str(ev, 12).Length > 0) { var bf = L("board_foot"); Lab(art, "BoardFoot", T(Str(ev, 12)), At(bf, 0), Col(bf, 1), 'm', 540f, a.iy1 - At(bf, 3), Col(bf, 2), 2f); } } // ---------- Info(Event) ---------- void AttendInfo() { var ev = AttRow(attEv); if (ev == null) return; var d = S.Save; var now = S.Now; AttTabs(); AttBannerInfo(ev, d, now); var a = AttLayout(ev); var days = EventData.Attend(attEv); int got = EventRules.AttGot(d, attEv); int next = EventRules.AttClaimable(d, attEv, now); for (int day = 1; day < days.Count; day++) { int i = day - 1; int c = i % a.cols, r = i / a.cols; float x = a.lx + c * (a.cw + a.gx), y = a.top + r * (a.ch + a.gy); DayCell(days[i], x, y, a.cw, a.ch, day == next, day <= got); } if (days.Count > 0) { int i = days.Count - 1; int c = i % a.cols, r = i / a.cols; float x = a.lx + c * (a.cw + a.gx), y = a.top + r * (a.ch + a.gy); float fw = a.cw * 2f + a.gx, fh = Mathf.Floor(a.ch * N("final", 0)); FinalCell(days[i], x, y + Mathf.Floor((a.ch - fh) * 0.5f) + N("final", 1), fw, fh, days.Count == next, days.Count <= got); } } /// 위 탭 2(화면 폭 반씩 · 고른 탭 = 붉은 + 윗면 광택 · 받을 칸 있는 다른 탭 = 붉은 점). void AttTabs() { var tabs = L("att_tabs"); var at = L("att_tab"); var ac = L("att_tab_col"); float x = At(at, 0), y = At(at, 1), h = At(at, 2), gap = At(at, 3); float tw = Mathf.Floor((1080f - 2f * x - gap * (tabs.Length - 1)) / tabs.Length); for (int k = 0; k < tabs.Length; k++) { string id = tabs[k]; var ev = AttRow(id); bool on = id == attEv; var img = Box(info, "AttTab_" + id, "card", Col(ac, on ? 0 : 1), x, y, tw, h); img.raycastTarget = true; string evId = id; img.gameObject.AddComponent