60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using MiniJSON;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TitleTableData : TableDataBase
|
|
{
|
|
public string Name, Desc;
|
|
public eItemGrade Grade;
|
|
public eStat Stat;
|
|
public float StatValue, ConditionValue;
|
|
public bool BiggerThan;
|
|
}
|
|
|
|
public class table_title : MonoBehaviour
|
|
{
|
|
public static table_title Ins;
|
|
|
|
public TextAsset m_json;
|
|
|
|
private List<TableDataBase> list_Data = new List<TableDataBase>();
|
|
|
|
private void Awake()
|
|
{
|
|
Ins = this;
|
|
|
|
Dictionary<string, object> jsonData = Json.Deserialize(m_json.text) as Dictionary<string, object>;
|
|
|
|
// ["items"]은 items.txt 안의 items를 가리킨다. 툴 우측 하단 파일 종류란에서 설정 가능.
|
|
List<object> obj = jsonData[GetType().Name] as List<object>;
|
|
|
|
foreach (object objt in obj)
|
|
{
|
|
var temp = new TitleTableData();
|
|
Dictionary<string, object> json = objt as Dictionary<string, object>;
|
|
|
|
temp.ID = int.Parse(json["ID"].ToString());
|
|
temp.Name = json["Name"].ToString();
|
|
temp.Desc = json["Desc"].ToString();
|
|
temp.Grade = (eItemGrade)int.Parse(json["Grade"].ToString());
|
|
temp.Stat = DSUtil.StringToEnum<eStat>(json["Stat"].ToString());
|
|
temp.StatValue = float.Parse(json["StatValue"].ToString());
|
|
temp.ConditionValue = float.Parse(json["ConditionValue"].ToString());
|
|
temp.BiggerThan = bool.Parse(json["BiggerThan"].ToString());
|
|
|
|
list_Data.Add(temp);
|
|
}
|
|
}
|
|
|
|
public List<TableDataBase> Get_DataList() { return list_Data; }
|
|
public List<TableDataBase> Get_DataList(eStat _stat) { return list_Data.FindAll(f=>(f as TitleTableData).Stat == _stat); }
|
|
public TitleTableData Get_Data(int _id) { return list_Data.Find(f => f.ID == _id) as TitleTableData; }
|
|
public string Get_TitleName(int _id)
|
|
{
|
|
if (_id < 1) return DSUtil.Format("{0}새싹[-]", MyValue.Get_GradeColor(1));
|
|
var title = Get_Data(_id);
|
|
return DSUtil.Format("{0}{1}[-]", MyValue.Get_GradeColor((int)title.Grade), title.Name);
|
|
}
|
|
}
|