167 lines
5.6 KiB
C#
167 lines
5.6 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
namespace TKS.OutGame
|
||
{
|
||
/// <summary>
|
||
/// 승급 장비 = 병종 5 × 부위 6 × 등급 7 = 210(gear_items.csv · 2026-11-20 장비 등급 드랍 요청서) · 등급 = gear_grades(일반 ~ 신화 · 순서 · 이름 · 색) ·
|
||
/// 병종 · 부위 = gear_kinds(n_slot = 승급 장비 칸) · 스테이지 드랍 = gear_drop_chapters(장 → 등급 가중치) + gear_drop_stages(스테이지 → 확률 ↑ 장비 · 몫 %).
|
||
/// </summary>
|
||
public class GearDb : ScriptableObject
|
||
{
|
||
[Serializable]
|
||
public class Item
|
||
{
|
||
public string id;
|
||
public string nameKo;
|
||
public string kind;
|
||
[Tooltip("gear_grades s_grade(white … red)")]
|
||
public string grade;
|
||
[Tooltip("등급 순서 1~ (gear_grades n_order · 합성 사슬 = 같은 병종 · 부위 아래 등급)")]
|
||
public int order;
|
||
public int sellGold;
|
||
public int dropFromChapter;
|
||
public string craftFrom;
|
||
public int craftCount;
|
||
public int craftBlueprint;
|
||
[Tooltip("병종 키(infantry · spear · cavalry · archer · strategist)")]
|
||
public string unitType = "";
|
||
[Tooltip("UI 테마 아이콘 id")]
|
||
public string icon = "";
|
||
[Tooltip("장착 능력치 %(표 값 · 지금 능력치 계산에는 쓰지 않음 = economy gear_bonus_pct)")]
|
||
public float statPct;
|
||
}
|
||
|
||
[Serializable]
|
||
public class Grade
|
||
{
|
||
public string grade = "";
|
||
public int order;
|
||
public string nameKo = "";
|
||
public string color = "";
|
||
}
|
||
|
||
[Serializable]
|
||
public class Kind
|
||
{
|
||
public string unitType = "";
|
||
public string unitKo = "";
|
||
public string kind = "";
|
||
public string kindKo = "";
|
||
public int slot;
|
||
public string nameKo = "";
|
||
public string icon = "";
|
||
}
|
||
|
||
[Serializable]
|
||
public class ChapterDrop
|
||
{
|
||
public int chapter;
|
||
public string[] grades = new string[0];
|
||
public float[] weights = new float[0];
|
||
}
|
||
|
||
[Serializable]
|
||
public class StageDrop
|
||
{
|
||
public int chapter;
|
||
public int stage;
|
||
public string unitType = "";
|
||
public string kind = "";
|
||
public float focusPct;
|
||
}
|
||
|
||
public List<Item> items = new List<Item>();
|
||
public List<Grade> grades = new List<Grade>();
|
||
public List<Kind> kinds = new List<Kind>();
|
||
public List<ChapterDrop> chapterDrops = new List<ChapterDrop>();
|
||
public List<StageDrop> stageDrops = new List<StageDrop>();
|
||
|
||
public Grade GradeOf(string g)
|
||
{
|
||
foreach (var x in grades)
|
||
if (x.grade == g) return x;
|
||
return null;
|
||
}
|
||
|
||
/// <summary>등급 색 목록(s_color 「;」 · 2개 이상 = 화면에서 순환하는 무지개).</summary>
|
||
public Color[] ColorsOf(string g)
|
||
{
|
||
var x = GradeOf(g);
|
||
if (x == null || string.IsNullOrEmpty(x.color)) return new Color[0];
|
||
var parts = x.color.Split(';');
|
||
var res = new List<Color>();
|
||
foreach (var p in parts)
|
||
{
|
||
Color c;
|
||
if (ColorUtility.TryParseHtmlString(p, out c)) res.Add(c);
|
||
}
|
||
return res.ToArray();
|
||
}
|
||
|
||
/// <summary>장비 등급 이름(gear_grades s_name_ko · 없으면 키).</summary>
|
||
public string GradeName(string g)
|
||
{
|
||
var x = GradeOf(g);
|
||
return x != null ? x.nameKo : g;
|
||
}
|
||
|
||
/// <summary>그 장의 드랍 등급 줄(표 끝을 넘는 장 = 마지막 줄).</summary>
|
||
public ChapterDrop DropFor(int chapter)
|
||
{
|
||
ChapterDrop last = null;
|
||
foreach (var c in chapterDrops)
|
||
{
|
||
if (c.chapter == chapter) return c;
|
||
if (last == null || c.chapter > last.chapter) last = c;
|
||
}
|
||
return last != null && chapter > last.chapter ? last : null;
|
||
}
|
||
|
||
public StageDrop FocusFor(int chapter, int stage)
|
||
{
|
||
foreach (var s in stageDrops)
|
||
if (s.chapter == chapter && s.stage == stage) return s;
|
||
return null;
|
||
}
|
||
|
||
/// <summary>병종 · 부위 · 등급 장비.</summary>
|
||
public Item Find(string unitType, string kind, string grade)
|
||
{
|
||
foreach (var i in items)
|
||
if (i.unitType == unitType && i.kind == kind && i.grade == grade) return i;
|
||
return null;
|
||
}
|
||
|
||
Dictionary<string, Item> index;
|
||
|
||
public Item Get(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id)) return null;
|
||
if (index == null || index.Count != items.Count)
|
||
{
|
||
index = new Dictionary<string, Item>();
|
||
foreach (var i in items) index[i.id] = i;
|
||
}
|
||
Item res;
|
||
return index.TryGetValue(id, out res) ? res : null;
|
||
}
|
||
|
||
public void InvalidateIndex()
|
||
{
|
||
index = null;
|
||
}
|
||
|
||
/// <summary>등급 id → 순서(gear_grades · 표가 없으면 장비에서 · 없으면 0).</summary>
|
||
public int OrderOf(string grade)
|
||
{
|
||
var g = GradeOf(grade);
|
||
if (g != null) return g.order;
|
||
foreach (var i in items)
|
||
if (i.grade == grade) return i.order;
|
||
return 0;
|
||
}
|
||
}
|
||
}
|