ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Data/GearDb.cs

57 lines
1.6 KiB
C#
Raw Permalink 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;
using System.Collections.Generic;
using UnityEngine;
namespace TKS.OutGame
{
/// <summary>승급 장비 12 종 × 5 등급(gear_items.csv). 등급 순서(order) = 합성 사슬 깊이(craft_from 없는 흰 = 1).</summary>
public class GearDb : ScriptableObject
{
[Serializable]
public class Item
{
public string id;
public string nameKo;
public string kind;
[Tooltip("white|green|blue|purple|orange")]
public string grade;
[Tooltip("등급 순서 1~ (합성 사슬 깊이)")]
public int order;
public int sellGold;
public int dropFromChapter;
public string craftFrom;
public int craftCount;
public int craftBlueprint;
}
public List<Item> items = new List<Item>();
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 → 순서(없으면 0).</summary>
public int OrderOf(string grade)
{
foreach (var i in items)
if (i.grade == grade) return i.order;
return 0;
}
}
}