2025-11-25 19:58:58 +00:00
|
|
|
using GUPS.AntiCheat.Protected;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
public class gacharateconfigtabledata
|
|
|
|
|
{
|
|
|
|
|
protected ProtectedInt32 _n_GachaGrade;
|
|
|
|
|
public int n_GachaGrade
|
|
|
|
|
{
|
|
|
|
|
get { return _n_GachaGrade; }
|
|
|
|
|
set { _n_GachaGrade = value; _n_GachaGrade.Obfuscate(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ProtectedInt32 _n_GachaGradeRate;
|
|
|
|
|
public int n_GachaGradeRate
|
|
|
|
|
{
|
|
|
|
|
get { return _n_GachaGradeRate; }
|
|
|
|
|
set { _n_GachaGradeRate = value; _n_GachaGrade.Obfuscate(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class table_gacharateconfig : table_base
|
|
|
|
|
{
|
|
|
|
|
public static table_gacharateconfig Ins;
|
|
|
|
|
|
|
|
|
|
List<gacharateconfigtabledata> tableDatas;
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
Ins = this;
|
|
|
|
|
base.Awake();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Start()
|
|
|
|
|
{
|
|
|
|
|
tableDatas = JsonConvert.DeserializeObject<List<gacharateconfigtabledata>>(json_last);
|
|
|
|
|
base.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public gacharateconfigtabledata Get_RadomData()
|
|
|
|
|
{
|
|
|
|
|
if (tableDatas == null || tableDatas.Count == 0)
|
|
|
|
|
return null;
|
|
|
|
|
|
2025-12-19 06:18:29 +00:00
|
|
|
List<gacharateconfigtabledata> targetList = tableDatas;
|
|
|
|
|
|
|
|
|
|
if (SaveMgr.Ins.GachaChargeTime_Reduce())
|
|
|
|
|
{
|
|
|
|
|
int minGrade = int.MaxValue;
|
|
|
|
|
for (int i = 0; i < tableDatas.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tableDatas[i].n_GachaGrade < minGrade)
|
|
|
|
|
minGrade = tableDatas[i].n_GachaGrade;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filtered = new List<gacharateconfigtabledata>();
|
|
|
|
|
for (int i = 0; i < tableDatas.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tableDatas[i].n_GachaGrade > minGrade)
|
|
|
|
|
filtered.Add(tableDatas[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filtered.Count > 0)
|
|
|
|
|
targetList = filtered;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 19:58:58 +00:00
|
|
|
int totalRate = 0;
|
2025-12-19 06:18:29 +00:00
|
|
|
foreach (var data in targetList)
|
2025-11-25 19:58:58 +00:00
|
|
|
{
|
|
|
|
|
totalRate += data.n_GachaGradeRate;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-19 06:18:29 +00:00
|
|
|
// 1 ~ totalRate
|
2025-11-25 19:58:58 +00:00
|
|
|
int rand = UnityEngine.Random.Range(1, totalRate + 1);
|
|
|
|
|
|
|
|
|
|
int cumulative = 0;
|
2025-12-19 06:18:29 +00:00
|
|
|
foreach (var data in targetList)
|
2025-11-25 19:58:58 +00:00
|
|
|
{
|
|
|
|
|
cumulative += data.n_GachaGradeRate;
|
|
|
|
|
if (rand <= cumulative)
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-19 06:18:29 +00:00
|
|
|
// fallback
|
|
|
|
|
return targetList[targetList.Count - 1];
|
2025-11-25 19:58:58 +00:00
|
|
|
}
|
|
|
|
|
}
|