78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class table_itemdatabase : MonoBehaviour
|
||
|
|
{
|
||
|
|
protected List<TableDataBase> list_Data = new List<TableDataBase>();
|
||
|
|
|
||
|
|
public EquipmentTableBase Read(eItem _item, Dictionary<string, object> json)
|
||
|
|
{
|
||
|
|
int grade = int.Parse(json["Grade"].ToString());
|
||
|
|
var temp = new EquipmentTableBase
|
||
|
|
{
|
||
|
|
ItemType = _item,
|
||
|
|
ID = int.Parse(json["ID"].ToString()),
|
||
|
|
Grade = (eItemGrade)grade,
|
||
|
|
Icon = json["Icon"].ToString(),
|
||
|
|
Name = json["Name"].ToString(),
|
||
|
|
Desc = json["Desc"].ToString(),
|
||
|
|
};
|
||
|
|
temp.Stone = grade * 4;
|
||
|
|
|
||
|
|
for (int i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
int index = i + 1;
|
||
|
|
string stat = DSUtil.Format("Stat{0}", index);
|
||
|
|
if (json.ContainsKey(stat))
|
||
|
|
temp.list_stat.Add(new StatInfo
|
||
|
|
{
|
||
|
|
Index = index,
|
||
|
|
Stat = DSUtil.StringToEnum<eStat>(json[stat].ToString()),
|
||
|
|
Value = float.Parse(json[DSUtil.Format("StatValue{0}", index)].ToString()),
|
||
|
|
PerLvValue = float.Parse(json[DSUtil.Format("StatValuePerLv{0}", index)].ToString()),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
return temp;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<TableDataBase> Get_DataList() { return list_Data; }
|
||
|
|
public List<ItemData> Get_ItemDatas(string _deck, eUICardType uitype)
|
||
|
|
{
|
||
|
|
var lst = new List<ItemData>();
|
||
|
|
for (int i = 0; i < list_Data.Count; i++)
|
||
|
|
lst.Add(Get_ItemData(_deck, uitype, list_Data[i].ID));
|
||
|
|
return lst;
|
||
|
|
}
|
||
|
|
public virtual EquipmentTableBase Get_Data(int _id)
|
||
|
|
{
|
||
|
|
for (int i = 0; i < list_Data.Count; i++)
|
||
|
|
{
|
||
|
|
if(list_Data[i].ID == _id) return list_Data[i] as EquipmentTableBase;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
protected ItemData Get_ItemData(string _deck, eUICardType uitype, int _id)
|
||
|
|
{
|
||
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
||
|
|
var wdata = Get_Data(_id);
|
||
|
|
var id = new ItemData(wdata.ItemType, wdata.ID, sdata.Get_ItemAmount(wdata.ItemType, wdata.ID), "", uitype);
|
||
|
|
id.Deck = _deck;
|
||
|
|
return id;
|
||
|
|
}
|
||
|
|
public List<StatInfo> Get_StatInfo(int _id) { return Get_Data(_id).list_stat; }
|
||
|
|
public double Get_StatValue(int _id, eStat _stat, int _lv)
|
||
|
|
{
|
||
|
|
var stat = Get_StatInfo(_id).Find(f => f.Stat == _stat);
|
||
|
|
if (stat != null)
|
||
|
|
return stat.Value + stat.PerLvValue * _lv;
|
||
|
|
return 0d;
|
||
|
|
}
|
||
|
|
public string Get_Icon(int _id)
|
||
|
|
{
|
||
|
|
var data = Get_Data(_id);
|
||
|
|
if (data == null) return "empty_slot_equipment";
|
||
|
|
return data.Icon;
|
||
|
|
}
|
||
|
|
}
|