72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Random = UnityEngine.Random;
|
|
|
|
[Serializable]
|
|
public class GachaRandomBagTableData : TableDataBase
|
|
{
|
|
ObscuredInt _ID;
|
|
public int n_ID
|
|
{
|
|
get { return _ID; }
|
|
set { _ID = value; _ID.RandomizeCryptoKey(); }
|
|
} // 랜덤백 고유 ID
|
|
|
|
ObscuredInt _Grade;
|
|
public int n_Grade
|
|
{
|
|
get { return _Grade; }
|
|
set { _Grade = value; _Grade.RandomizeCryptoKey(); }
|
|
} // 아이템 등급
|
|
|
|
ObscuredInt _RewardID;
|
|
public int n_RewardID
|
|
{
|
|
get { return _RewardID; }
|
|
set { _RewardID = value; _RewardID.RandomizeCryptoKey(); }
|
|
}
|
|
}
|
|
|
|
public class table_gacharandombag : table_missionbase
|
|
{
|
|
public static table_gacharandombag Ins;
|
|
List<GachaRandomBagTableData> tableDatas;
|
|
// (n_ID, n_Grade)
|
|
Dictionary<(int, int), List<ItemSimpleData>> dic_ItemData = new Dictionary<(int, int), List<ItemSimpleData>>();
|
|
// (n_ID, n_Grade)
|
|
Dictionary<(int, int), List<GachaRandomBagTableData>> dic_bagData = new Dictionary<(int, int), List<GachaRandomBagTableData>>();
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
Ins = this;
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
tableDatas = JsonConvert.DeserializeObject<List<GachaRandomBagTableData>>(json_last);
|
|
for (int i = 0; i < Get_DataList().Count; i++)
|
|
{
|
|
var temp = Get_DataList()[i];
|
|
|
|
if (!dic_ItemData.ContainsKey((temp.n_ID, temp.n_Grade)))
|
|
dic_ItemData.Add((temp.n_ID, temp.n_Grade), new List<ItemSimpleData>());
|
|
dic_ItemData[(temp.n_ID, temp.n_Grade)].Add(new ItemSimpleData { itemid = temp.n_RewardID, amount = 1 });
|
|
|
|
if (!dic_bagData.ContainsKey((temp.n_ID, temp.n_Grade)))
|
|
dic_bagData.Add((temp.n_ID, temp.n_Grade), new List<GachaRandomBagTableData>());
|
|
dic_bagData[(temp.n_ID, temp.n_Grade)].Add(temp);
|
|
}
|
|
|
|
base.Start();
|
|
}
|
|
|
|
public ItemSimpleData Get_RandomItemData(int index, int grade)
|
|
{
|
|
return dic_ItemData[(index, grade)][Random.Range(0, dic_ItemData[(index, grade)].Count)];
|
|
}
|
|
public List<GachaRandomBagTableData> Get_DataList() { return tableDatas; }
|
|
public List<GachaRandomBagTableData> Get_DataList(int index, int grade) { return dic_bagData[(index, grade)]; }
|
|
} |