nightward/Assets/ResWork/Table/table_album.cs

73 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
.Take(index) // data <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.Where(t => t.e_CollectionMethod == eCollectionMethod.Normal)
.Reverse() // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͺ<EFBFBD><CDBA><EFBFBD>
.ToList();
}
public albumtabledata Get_Data(int index) { return Get_DataList().Find(f => f.n_Index == index); }
}