nightward/Assets/ResWork/Table/table_album.cs

72 lines
2.6 KiB
C#

using System.Collections.Generic;
using System.Linq;
using GUPS.AntiCheat.Protected;
using Newtonsoft.Json;
public enum eCollectionMethod { Default, Normal, Gacha, FullCollection, Mission }
public class albumtabledata : ShowAlbumBase
{
public int n_Index;
ProtectedInt32 _GirlID; public int n_GirlID { get { return _GirlID; } set { _GirlID = value; _GirlID.Obfuscate(); } }
ProtectedInt32 _Price; public int n_Price { get { return _Price; } set { _Price = value; _Price.Obfuscate(); } }
public eCollectionMethod e_CollectionMethod;
}
public class table_album : table_base
{
public static table_album Ins;
List<albumtabledata> tableDatas;
Dictionary<int, List<albumtabledata>> dic_datas = new Dictionary<int, List<albumtabledata>>();
Dictionary<eCollectionMethod, List<albumtabledata>> dic_Methods = new Dictionary<eCollectionMethod, List<albumtabledata>>
{
{ eCollectionMethod.Default, new List<albumtabledata>() },
{ eCollectionMethod.FullCollection, new List<albumtabledata>() },
};
protected override void Awake()
{
Ins = this;
base.Awake();
}
protected override void Start()
{
tableDatas = JsonConvert.DeserializeObject<List<albumtabledata>>(json_last);
for (int i = 0; i < tableDatas.Count; i++)
{
var temp = tableDatas[i];
if (!dic_datas.ContainsKey(temp.n_GirlID))
dic_datas.Add(temp.n_GirlID, new List<albumtabledata>());
dic_datas[temp.n_GirlID].Add(temp);
if (dic_Methods.ContainsKey(temp.e_CollectionMethod))
dic_Methods[temp.e_CollectionMethod].Add(temp);
}
base.Start();
}
public List<albumtabledata> Get_DataList() { return tableDatas; }
public List<albumtabledata> Get_DataList(int girl) { return dic_datas[girl]; }
public List<albumtabledata> Get_DataList(eCollectionMethod method) { return dic_Methods[method]; }
public List<albumtabledata> Get_AlbumDataList(int girl)
{
return Get_DataList(girl).FindAll(f => f.e_CollectionMethod == eCollectionMethod.Normal);
}
public albumtabledata Get_SpecialAlbum(int girl, eCollectionMethod method)
{
return Get_DataList(girl).Find(f => f.e_CollectionMethod == method);
}
public List<albumtabledata> Get_PreDatas(albumtabledata data)
{
int index = tableDatas.FindIndex(t => t.n_Index == data.n_Index);
if (index <= 0) return null;
return tableDatas
.GetRange(0, index)
.AsEnumerable()
.Reverse()
.ToList();
}
}