85 lines
2.8 KiB
C#
85 lines
2.8 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
[Serializable]
|
|
public class RandomBagTableData : TableDataBase
|
|
{
|
|
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(); }
|
|
} // 드랍 수량
|
|
}
|
|
|
|
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>>();
|
|
|
|
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 });
|
|
}
|
|
|
|
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; }
|
|
} |