Project_WL/Assets/Script/Table/Common/table_randombag.cs

91 lines
3.2 KiB
C#
Raw Permalink Normal View History

2024-12-18 03:48:42 +00:00
using CodeStage.AntiCheat.ObscuredTypes;
2024-12-15 01:39:39 +00:00
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
[Serializable]
public class RandomBagTableData : TableDataBase
{
2024-12-18 03:48:42 +00:00
ObscuredInt _DropIndex;
public int n_DropIndex
{
get { return _DropIndex; }
set { _DropIndex = value; _DropIndex.RandomizeCryptoKey(); }
} // 랜덤백 고유 ID
ObscuredInt _ItemGrade;
public int n_ItemGrade
{
get { return _ItemGrade; }
set { _ItemGrade = value; _ItemGrade.RandomizeCryptoKey(); }
} // 아이템 등급
ObscuredInt _ItemId;
public int n_ItemId
{
get { return _ItemId; }
set { _ItemId = value; _ItemId.RandomizeCryptoKey(); }
} // 드랍 타입 별 ID
ObscuredFloat _DropRate;
public float f_DropRate
{
get { return _DropRate; }
set { _DropRate = value; _DropRate.RandomizeCryptoKey(); }
} // 드랍 확률
ObscuredInt _DropCount;
public int n_DropCount
{
get { return _DropCount; }
set { _DropCount = value; _DropCount.RandomizeCryptoKey(); }
} // 드랍 수량
2024-12-15 01:39:39 +00:00
}
public class table_randombag : table_missionbase
{
public static table_randombag Ins;
List<RandomBagTableData> tableDatas;
Dictionary<(int, int), List<float>> dic_RateData = new Dictionary<(int, int), List<float>>();
Dictionary<(int, int), List<ItemSimpleData>> dic_ItemData = new Dictionary<(int, int), List<ItemSimpleData>>();
2025-03-09 05:52:14 +00:00
Dictionary<int, List<RandomBagTableData>> dic_ItemList = new Dictionary<int, List<RandomBagTableData>>();
2024-12-15 01:39:39 +00:00
protected override void Awake()
{
base.Awake();
Ins = this;
}
protected override void Start()
{
tableDatas = JsonConvert.DeserializeObject<List<RandomBagTableData>>(json_last);
for (int i = 0; i < Get_DataList().Count; i++)
{
var temp = Get_DataList()[i];
if (!dic_RateData.ContainsKey((temp.n_DropIndex, temp.n_ItemGrade)))
dic_RateData.Add((temp.n_DropIndex, temp.n_ItemGrade), new List<float>());
dic_RateData[(temp.n_DropIndex, temp.n_ItemGrade)].Add(temp.f_DropRate);
if (!dic_ItemData.ContainsKey((temp.n_DropIndex, temp.n_ItemGrade)))
dic_ItemData.Add((temp.n_DropIndex, temp.n_ItemGrade), new List<ItemSimpleData>());
dic_ItemData[(temp.n_DropIndex, temp.n_ItemGrade)].Add(new ItemSimpleData { itemid = temp.n_ItemId, amount = temp.n_DropCount });
2025-03-09 05:52:14 +00:00
if (!dic_ItemList.ContainsKey(temp.n_DropIndex))
dic_ItemList.Add(temp.n_DropIndex, new List<RandomBagTableData>());
dic_ItemList[temp.n_DropIndex].Add(temp);
2024-12-15 01:39:39 +00:00
}
base.Start();
}
public ItemSimpleData Get_RandomItemData(int index, int grade)
{
var itemindex = DSUtil.Get_RandomIndex(Get_Rate(index, grade));
return dic_ItemData[(index, grade)][itemindex];
}
public List<float> Get_Rate(int index, int grade) { return dic_RateData[(index, grade)]; }
public RandomBagTableData Get_Data(int itemid) { return Get_DataList().Find(f => f.n_ItemId == itemid); }
public List<RandomBagTableData> Get_DataList() { return tableDatas; }
2025-03-09 05:52:14 +00:00
public List<RandomBagTableData> Get_DataList(int id) { return dic_ItemList[id]; }
2024-12-15 01:39:39 +00:00
}