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 tableDatas; protected override void Awake() { Ins = this; base.Awake(); } protected override void Start() { tableDatas = JsonConvert.DeserializeObject>(json_last); base.Start(); } public gacharateconfigtabledata Get_RadomData() { if (tableDatas == null || tableDatas.Count == 0) return null; List 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(); for (int i = 0; i < tableDatas.Count; i++) { if (tableDatas[i].n_GachaGrade > minGrade) filtered.Add(tableDatas[i]); } if (filtered.Count > 0) targetList = filtered; } int totalRate = 0; foreach (var data in targetList) { totalRate += data.n_GachaGradeRate; } // 1 ~ totalRate int rand = UnityEngine.Random.Range(1, totalRate + 1); int cumulative = 0; foreach (var data in targetList) { cumulative += data.n_GachaGradeRate; if (rand <= cumulative) return data; } // fallback return targetList[targetList.Count - 1]; } }