50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
|
|
using MiniJSON;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class ShopPackgeTableData : TableDataBase
|
||
|
|
{
|
||
|
|
public List<ItemSimpleData> itemdata = new List<ItemSimpleData>();
|
||
|
|
}
|
||
|
|
|
||
|
|
public class table_shoppackage : MonoBehaviour
|
||
|
|
{
|
||
|
|
public static table_shoppackage 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 ShopPackgeTableData();
|
||
|
|
Dictionary<string, object> json = objt as Dictionary<string, object>;
|
||
|
|
|
||
|
|
temp.ID = int.Parse(json["ID"].ToString());
|
||
|
|
for (int i = 0; i < 6; i++)
|
||
|
|
{
|
||
|
|
var split = json[DSUtil.Format("Item{0}", i + 1)].ToString().Split(',');
|
||
|
|
temp.itemdata.Add(new ItemSimpleData
|
||
|
|
{
|
||
|
|
itemid = int.Parse(split[1]),
|
||
|
|
amount = double.Parse(split[2]),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
list_Data.Add(temp);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<TableDataBase> Get_DataList() { return list_Data; }
|
||
|
|
public ShopPackgeTableData Get_Data(int _id) { return list_Data.Find(f => f.ID == _id) as ShopPackgeTableData; }
|
||
|
|
}
|