Project_WL/Assets/Script/Table/table_itemlist.cs

95 lines
3.7 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[Serializable]
public class ItemListTableData : TableDataBase
{
public int n_ItemID; // 아이템 고유 ID
public int n_ItemGrade; // 아이템 등급 분류 (UI 구성용)
public eItem e_ItemType; // 아이템의 분류 타입
public int n_ItemValue; // 아이템 속성 값
public int n_ItemName; // 아이템 이름 정보
public int n_ItemDesc; // 아이템 설명 정보
public string s_ItemIcon; // 아이템 아이콘 리소스 경로
public int n_ItemOrder; // 아이템 정렬 순서
public bool b_isSaveModeShow; // 절전 모드 표시 유무
public int n_LinkPointID1; // 획득처 바로가기1
public int n_LinkPointID2; // 획득처 바로가기2
public int n_LinkPointID3; // 획득처 바로가기3
public int n_LinkPointID4; // 획득처 바로가기4
public int n_LinkPointID5; // 획득처 바로가기5
public Sprite Get_IconSprite() { return UIAtlasMgr.Ins.Get_Sprite(s_ItemIcon); }
public Sprite Get_GradeSprite() { return UIAtlasMgr.Ins.Get_GradeSprite(n_ItemGrade); }
public override string Get_Name() { return table_localtext.Ins.Get_Text(n_ItemName); }
public string Get_Desc() { return table_localtext.Ins.Get_Text(n_ItemDesc); }
public string Get_GradeName() { return table_localtext.Ins.Get_Text(30000 + n_ItemGrade); }
public string Get_ItemTypeName()
{
switch (e_ItemType)
{
case eItem.Weapon: return table_localtext.Ins.Get_Text(30101);
case eItem.Armor: return table_localtext.Ins.Get_Text(30102);
case eItem.Helmet: return table_localtext.Ins.Get_Text(30103);
case eItem.Extra: return table_localtext.Ins.Get_Text(30104);
case eItem.Necklace: return table_localtext.Ins.Get_Text(30105);
case eItem.Ring: return table_localtext.Ins.Get_Text(30106);
}
return "";
}
public bool IsEquipItem()
{
switch (e_ItemType)
{
case eItem.Weapon:
case eItem.Armor:
case eItem.Helmet:
case eItem.Extra:
case eItem.Necklace:
case eItem.Ring:
return true;
}
return false;
}
}
public class table_itemlist : table_missionbase
{
public static table_itemlist Ins;
List<ItemListTableData> tableDatas;
Dictionary<eItem, List<ItemListTableData>> dic_itemlist = new Dictionary<eItem, List<ItemListTableData>>();
Dictionary<int, ItemListTableData> dic_items = new Dictionary<int, ItemListTableData>();
protected override void Awake()
{
base.Awake();
Ins = this;
}
protected override void Start()
{
tableDatas = JsonConvert.DeserializeObject<List<ItemListTableData>>(json_last);
for (int i = 0; i < Get_DataList().Count; i++)
{
var temp = Get_DataList()[i];
var itemtype = temp.e_ItemType;
if (!dic_itemlist.ContainsKey(itemtype))
dic_itemlist.Add(itemtype, new List<ItemListTableData>());
dic_itemlist[itemtype].Add(temp);
dic_items.Add(temp.n_ItemID, temp);
}
foreach (var key in dic_itemlist.Keys.ToList())
dic_itemlist[key] = dic_itemlist[key].OrderBy(item => item.n_ItemOrder).ToList();
base.Start();
}
public ItemListTableData Get_Data(int id) { return dic_items.ContainsKey(id) ? dic_items[id] : null; }
public List<ItemListTableData> Get_DataList() { return tableDatas; }
public List<ItemListTableData> Get_DataList(eItem item) { return dic_itemlist[item]; }
}