using GUPS.AntiCheat.Protected; using Newtonsoft.Json; using System; using System.Collections; using TigerForge; public class SaveMgr : MonoBehaviourSingletonTemplate { EasyFileSave _EasyFile; EasyFileSave m_EasyFile { get { if (_EasyFile == null) { _EasyFile = new EasyFileSave(); m_EasyFile.Load("shegotwet"); } return _EasyFile; } } public SaveData m_SaveData; IEnumerator Start() { Load(); while (!LobbyUI.Ins) yield return null; LobbyUI.Ins.Set_Money(); } public void Load() { m_SaveData = (SaveData)m_EasyFile.GetDeserialized("SaveData", typeof(SaveData)); if (m_SaveData == null) { m_SaveData = new SaveData { bSound = true, bBgm = true, Attendance = 0, MoneyChatCoin = 0, MoneyGacha = 0, MoneyHeart = 0, MoneyLucky = 0, SelectGirlID = 1, LastDoY = 0, AttendanceDoY = 0, GirlUnLockIndex = 1 }; } } public string Get_SaveDataJson() { return JsonConvert.SerializeObject(m_SaveData); } public void Save() { if (m_SaveData != null) { m_EasyFile.AddSerialized("SaveData", m_SaveData); m_EasyFile.Save("shegotwet"); } } public void Set_Option(eOption option) { switch (option) { case eOption.Sound: m_SaveData.bSound = !m_SaveData.bSound; break; case eOption.Bgm: m_SaveData.bBgm = !m_SaveData.bBgm; break; } Save(); } public bool Get_Option(eOption option) { switch (option) { case eOption.Sound: return m_SaveData.bSound; case eOption.Bgm: return m_SaveData.bBgm; } return false; } public int Get_DoY() { return m_SaveData.LastDoY; } public int Get_WOY() { return m_SaveData.WeekOfYear; } public void Add_Money(eMoney money, int add = 1) { switch (money) { case eMoney.AlbumOpen: m_SaveData.MoneyHeart+= add; break; case eMoney.Chat: m_SaveData.MoneyChatCoin += add; break; case eMoney.Gacha: m_SaveData.MoneyGacha += add; break; case eMoney.Lucky: m_SaveData.MoneyLucky += add; break; } LobbyUI.Ins.Set_Money(); } public int Get_Money(eMoney money) { switch (money) { case eMoney.AlbumOpen: return m_SaveData.MoneyHeart; case eMoney.Chat: return m_SaveData.MoneyChatCoin; case eMoney.Gacha: return m_SaveData.MoneyGacha; case eMoney.Lucky: return m_SaveData.MoneyLucky; } return 0; } public bool Check_Money(eMoney money, int amount, bool showToast = true) { var enough = Get_Money(money) >= amount; if (!enough && showToast) LobbyUI.Ins.m_ToastUI.Set("재화가 부족합니다."); return enough; } public void DailyCheck() { m_SaveData.LastDoY = InternetTime.Ins.Time.DayOfYear; if (m_SaveData.Attendance >= 7) m_SaveData.Attendance = 0; Save(); } public void WeeklyCheck(int woy) { m_SaveData.WeekOfYear = woy; m_SaveData.BuyShopWeekly = false; Save(); } public void Add_AttendanceDay() { ++m_SaveData.Attendance; } public int Get_AttendanceDay() { return m_SaveData.Attendance; } public bool CanGet_Attandance(int day) { return Get_AttendanceDay() < day && m_SaveData.AttendanceDoY != m_SaveData.LastDoY; } public bool CanGet_Attandance() { var lst = table_attandance.Ins.Get_DataList(); for (int i = 0; i < lst.Count; i++) { if (CanGet_Attandance(lst[i].n_Day)) return true; } return false; } public void Get_AttandanceReward() { Add_AttendanceDay(); var curDay = Get_AttendanceDay(); var data = table_attandance.Ins.Get_Data(curDay); Add_Money(eMoney.Gacha, data.n_GachaAmount); m_SaveData.AttendanceDoY = InternetTime.Ins.Time.DayOfYear; Save(); } public int Get_UnLockIndex() { return m_SaveData.GirlUnLockIndex; } public int Get_SelectGirlID() { return m_SaveData.SelectGirlID; } public bool CanShowShopAD(bool showtoast = true) { var cal = m_SaveData.ShopADTime - InternetTime.Ins.Time; var canshow = cal.TotalSeconds <= 0; if (!canshow && showtoast) LobbyUI.Ins.m_ToastUI.Set($"{cal} 남음"); return canshow; } public void Add_ShopADTime(int sec) { m_SaveData.ShopADTime = InternetTime.Ins.Time.AddSeconds(sec); Save(); } public bool CanBuyShopPackage(eInAppInitType inittype) { switch (inittype) { default: return true; case eInAppInitType.Week: return !m_SaveData.BuyShopWeekly; case eInAppInitType.Mini_One: return !m_SaveData.BuyShopMiniGame; case eInAppInitType.One1: return !m_SaveData.BuyShopOne1; case eInAppInitType.One2: return !m_SaveData.BuyShopOne2; } } public void Set_ShopInit(eInAppInitType inittype) { switch (inittype) { case eInAppInitType.Week: m_SaveData.BuyShopWeekly = true; break; case eInAppInitType.Mini_One: m_SaveData.BuyShopMiniGame = true; break; case eInAppInitType.One1: m_SaveData.BuyShopOne1 = true; break; case eInAppInitType.One2: m_SaveData.BuyShopOne2 = true; break; } } public class SaveData { public bool bSound, bBgm; ProtectedInt32 _LastDoY; public int LastDoY { get { return _LastDoY; } set { _LastDoY = value; _LastDoY.Obfuscate(); } } ProtectedInt32 _WeekOfYear; public int WeekOfYear { get { return _WeekOfYear; } set { _WeekOfYear = value; _WeekOfYear.Obfuscate(); } } ProtectedInt32 _GirlSelectIndex; public int SelectGirlID { get { return _GirlSelectIndex; } set { _GirlSelectIndex = value; _GirlSelectIndex.Obfuscate(); } } ProtectedInt32 _GirlUnLockIndex; public int GirlUnLockIndex { get { return _GirlUnLockIndex; } set { _GirlUnLockIndex = value; _GirlUnLockIndex.Obfuscate(); } } ProtectedInt32 _AttendanceDoY; public int AttendanceDoY { get { return _AttendanceDoY; } set { _AttendanceDoY = value; _AttendanceDoY.Obfuscate(); } } ProtectedInt32 _Attendance; public int Attendance { get { return _Attendance; } set { _Attendance = value; _Attendance.Obfuscate(); } } ProtectedInt32 _MoneyHeart; public int MoneyHeart { get { return _MoneyHeart; } set { _MoneyHeart = value; _MoneyHeart.Obfuscate(); } } ProtectedInt32 _MoneyChatCoin; public int MoneyChatCoin { get { return _MoneyChatCoin; } set { _MoneyChatCoin = value; _MoneyChatCoin.Obfuscate(); } } ProtectedInt32 _MoneyGacha; public int MoneyGacha { get { return _MoneyGacha; } set { _MoneyGacha = value; _MoneyGacha.Obfuscate(); } } ProtectedInt32 _MoneyLucky; public int MoneyLucky { get { return _MoneyLucky; } set { _MoneyLucky = value; _MoneyLucky.Obfuscate(); } } ProtectedDateTime _ShopADTime; public DateTime ShopADTime { get { return _ShopADTime; } set { _ShopADTime = value; _ShopADTime.Obfuscate(); } } ProtectedBool _BuyShopWeekly; public bool BuyShopWeekly { get { return _BuyShopWeekly; } set { _BuyShopWeekly = value; _BuyShopWeekly.Obfuscate(); } } ProtectedBool _BuyShopMiniGame; public bool BuyShopMiniGame { get { return _BuyShopMiniGame; } set { _BuyShopMiniGame = value; _BuyShopMiniGame.Obfuscate(); } } ProtectedBool _BuyShopOne1; public bool BuyShopOne1 { get { return _BuyShopOne1; } set { _BuyShopOne1 = value; _BuyShopOne1.Obfuscate(); } } ProtectedBool _BuyShopOne2; public bool BuyShopOne2 { get { return _BuyShopOne2; } set { _BuyShopOne2 = value; _BuyShopOne2.Obfuscate(); } } } }