ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Arena/ArenaScreen.Raid.cs

204 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>
/// 맹장 토벌전 화면(컨텐츠 모드 기획 10판 ③ · 2026-11-18) — **더미 UI**(개발 요청서 §G): 메인 맹장 전용 배너 자리 · 서브 띠 · 기록 도전 · 연습 · 주간 점수 · 누적 단계 · 훈장 상점.
/// 배너 그림 = `Resources/ContentModes/Art/&lt;아트 목록 id&gt;`(raid_banner_&lt;맹장&gt; · 여포 = 지금 픽업 배너 사본) — 파일이 없으면 색 판 + 유닛 그림 + 글자.
/// 그림이 납품되면 같은 이름의 파일만 넣으면 바뀐다.
/// </summary>
public partial class ArenaScreen
{
public const string ContentArtRoot = "ContentModes/Art/";
void BuildRaid2()
{
ContentTables.Reload();
var d = S.Save;
var now = S.Now;
Title("맹장 토벌전", ArenaRules.Raid);
if (!RaidRules.Unlocked(d))
{
UiKit.Label(root, ContentTables.Str(RaidData.Mode, "unlock_stage") + " 클리어 뒤 열립니다", 36, UiKit.Red, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -200f), new Vector2(1000f, 60f), false);
return;
}
string mainId = RaidRules.BossOf(d, RaidData.Main, now), subId = RaidRules.BossOf(d, RaidData.Sub, now);
var main = RaidData.Get(mainId);
// 메인 배너(1016×624 비율 · 더미 화면 = 상점까지 한 화면에 들게 줄임)
float bw = 1032f, bh = 460f;
RaidBanner(main, 120f, bw, bh, false);
float y = 120f + bh + 10f;
RaidRow(RaidData.Main, main, y, 120f);
y += 128f;
var sub = RaidData.Get(subId);
if (sub != null)
{
float sh = 150f;
RaidBanner(sub, y, bw, sh, true);
RaidRow(RaidData.Sub, sub, y + sh + 6f, 120f);
y += sh + 134f;
}
// 주간 점수 · 누적 단계
var sc = Panel("Score", y, 130f);
var rs = d.raid;
string rank = rs.serverView && rs.rank > 0 ? " · " + rs.rank + "위 / " + rs.rankTotal : (S.RankAvailable ? "" : " · 순위 = 서버 연결 때");
UiKit.Label(sc, "이번 주 점수 " + rs.score.ToString("N0") + rank + "\n메인 " + rs.mainDamage.ToString("N0") + " × " + RaidData.ScoreMult(RaidData.Main) + " + 서브 " + rs.subDamage.ToString("N0") + " · 훈장 " + rs.coins, 28, UiKit.Ink, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(20f, -12f), new Vector2(990f, 80f), false);
var steps = new List<string>();
foreach (var r in ContentTables.Rows(RaidData.Rewards))
if (r.S("e_kind") == "milestone") steps.Add((rs.milestones.Contains(r.I("n_step")) ? "● " : "○ ") + r.I("n_score_min").ToString("N0"));
UiKit.Label(sc, "누적 단계 " + string.Join(" ", steps.ToArray()), 24, UiKit.InkSoft, TextAnchor.MiddleLeft, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(20f, 10f), new Vector2(990f, 44f), false);
y += 138f;
RaidShop(y);
}
void RaidBanner(RaidData.Boss b, float top, float w, float h, bool strip)
{
if (b == null) return;
var art = ContentTables.Find("content_modes_art_list", "s_id", "raid_banner_" + b.id);
var sp = Resources.Load<Sprite>(ContentArtRoot + (art != null ? art.S("s_id") : "raid_banner_" + b.id));
var box = UiKit.Box("Banner_" + b.id, root, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -top), new Vector2(w, h), sp != null ? Color.white : UiKit.Dark);
box.raycastTarget = false;
if (sp != null)
{
box.sprite = sp;
box.type = Image.Type.Simple;
box.preserveAspect = !strip;
if (strip) // 서브 띠 = 같은 그림을 가로로 자른 것(raid.banner_sub_crop · 얼굴 = 오른쪽) — 그림 아래쪽을 가린 마스크로 대신
{
box.sprite = null;
box.color = UiKit.Dark;
var m = box.gameObject.AddComponent<RectMask2D>();
var inner = UiKit.Box("Img", box.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(w, w * 624f / 1016f), Color.white);
inner.sprite = sp;
inner.raycastTarget = false;
m.enabled = true;
}
}
else
{
var portrait = UiKit.ArtSprite(b.art); // 더미 = 색 판 + 유닛 그림(오른쪽) + 이름(왼쪽)
if (portrait != null)
{
var pi = UiKit.Box("Portrait", box.transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-20f, 0f), new Vector2(h * 0.95f, h * 0.95f), Color.white);
pi.sprite = portrait;
pi.preserveAspect = true;
pi.raycastTarget = false;
}
}
string head = (strip ? "서브 · " : "메인 · ") + b.nameKo + " <size=" + (strip ? 26 : 32) + ">" + b.titleKo + "</size>";
UiKit.Title(UiKit.Label(box.transform, head, strip ? 38 : 52, UiKit.White, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(24f, -14f), new Vector2(w * 0.7f, strip ? 60f : 80f)), true);
if (!strip)
UiKit.Title(UiKit.Label(box.transform, "군령 " + b.orderBuffKo + "\n패턴 " + b.patternKo + "\n빈틈 " + b.weakKo, 24, UiKit.White, TextAnchor.LowerLeft, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(24f, 16f), new Vector2(w * 0.62f, h * 0.55f), false), true);
}
void RaidRow(string slot, RaidData.Boss b, float top, float h)
{
if (b == null) return;
var d = S.Save;
var row = Panel("Row_" + slot, top, h);
int used = RaidRules.Used(d, slot, S.Now), limit = RaidData.EntryLimit(slot);
UiKit.Label(row, (slot == RaidData.Main ? "메인(한 주) · 점수 ×" : "서브(오늘) · 점수 ×") + RaidData.ScoreMult(slot) + "\n기록 도전 " + (limit - used) + " / " + limit, 28, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(20f, 0f), new Vector2(480f, h - 10f), false);
var why = RaidRules.Can(d, slot, false, S.Now);
var go = UiKit.Btn("Go", row, "도전", 34, why == null ? UiKit.Red : UiKit.Disabled, UiKit.White, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-250f, 0f), new Vector2(220f, 110f), () => RaidGo(slot, false));
go.interactable = why == null;
var pr = UiKit.Btn("Practice", row, "연습", 34, UiKit.Dark, UiKit.White, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-16f, 0f), new Vector2(220f, 110f), () => RaidGo(slot, true));
pr.interactable = RaidRules.Can(d, slot, true, S.Now) == null;
}
void RaidShop(float top)
{
var d = S.Save;
var rows = ContentTables.Rows(RaidData.Shop);
var box = Panel("Shop", top, 70f + rows.Count * 74f);
UiKit.Label(box, "훈장 상점 · 보유 " + d.raid.coins, 30, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(20f, -8f), new Vector2(700f, 56f), false);
for (int i = 0; i < rows.Count; i++)
{
var r = rows[i];
string item = r.S("s_item");
int bought = RaidRules.Bought(d, item, S.Now), limit = r.I("n_weekly_limit");
float ry = -66f - i * 74f;
UiKit.Label(box, r.S("s_name_ko") + " ×" + r.I("n_amount") + " · " + r.I("n_price") + " 훈장 · 이번 주 " + bought + "/" + limit, 26, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(20f, ry), new Vector2(760f, 64f), false);
var b = UiKit.Btn("Buy" + i, box, "구매", 28, bought < limit ? UiKit.Jade : UiKit.Disabled, UiKit.White, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-16f, ry), new Vector2(180f, 62f), () => RaidBuyPick(item, r.S("e_pick")));
b.interactable = bought < limit;
}
}
/// <summary>고르는 물품(owned_choice) = 보유 중에서 고른다 — 더미: 보유 목록 앞쪽 4개를 버튼으로.</summary>
void RaidBuyPick(string item, string pick)
{
if (pick != "owned_choice")
{
RaidBuy(item, "");
return;
}
var d = S.Save;
var buttons = new List<OutGameRoot.ModalButton>();
if (item == "arcana_shard")
{
foreach (var t in d.inv.treasures)
{
if (buttons.Count >= 4) break;
var def = S.Db.Treasures.Get(t.id);
string id = t.id;
buttons.Add(new OutGameRoot.ModalButton(def != null ? def.nameKo : id, UiKit.Dark, () => RaidBuy(item, id)));
}
}
else
foreach (var h in d.heroes)
{
if (buttons.Count >= 4) break;
var def = S.Db.Heroes.Get(h.id);
string id = h.id;
buttons.Add(new OutGameRoot.ModalButton(def != null ? def.nameKo : id, UiKit.Dark, () => RaidBuy(item, id)));
}
if (buttons.Count == 0)
{
Root.Toast("고를 수 있는 보유 항목이 없습니다");
return;
}
Root.Modal("무엇을 살까요", "보유한 것 가운데 고릅니다(더미 — 앞쪽 4개)", buttons.ToArray());
}
void RaidBuy(string item, string pick)
{
S.RaidBuy(item, pick, why =>
{
Root.Toast(why ?? "구매 완료");
if (page == 4) Refresh();
});
}
void RaidGo(string slot, bool practice)
{
var d = S.Save;
string bossId = RaidRules.BossOf(d, slot, S.Now);
var b = RaidData.Get(bossId);
if (b == null)
{
Root.Toast("맹장 표 없음");
return;
}
var cfg = Root.Battle.Config;
var refSt = ContentEnemyRef.RefStage(cfg, 3);
var stage = new BalanceConfig.StageDef { title = "맹장 토벌전 — " + b.nameKo, subtitle = slot == RaidData.Main ? "메인" : "서브", kind = StageKind.Boss, aiAccuracy = refSt != null ? refSt.aiAccuracy : 1f, aiAggroRange = 999f };
var rules = new RaidBattleRules { Boss = b, Slot = slot, Practice = practice, Config = cfg };
var why = rules.Prepare(stage);
if (why != null)
{
Root.Toast(why);
return;
}
var w = S.RaidEnter(slot, practice);
if (w != null)
{
Root.Toast(w);
return;
}
int index = (slot == RaidData.Sub ? 1 : 0) + (practice ? 2 : 0);
Root.StartMode(RaidRules.Kind, bossId, index, stage, ContentTables.Int(RaidData.Mode, "safety_max_turns"), 4, rules);
}
}
}