356 lines
14 KiB
C#
356 lines
14 KiB
C#
using GUPS.AntiCheat.Protected;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using TigerForge;
|
|
using UnityEngine;
|
|
|
|
public class SaveMgr : MonoBehaviourSingletonTemplate<SaveMgr>
|
|
{
|
|
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();
|
|
yield return null;
|
|
SoundInfo.Ins.Play_BGM(eBGM.b008_Title);
|
|
SoundInfo.Ins.Play_OneShot(eSound.s012_Title);
|
|
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,
|
|
MiniGameHP = table_GlobalValue.Ins.Get_Int("MiniGame_TotalEnterMoney")
|
|
};
|
|
}
|
|
}
|
|
|
|
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;
|
|
m_SaveData.MoneyHeart = Mathf.Max(m_SaveData.MoneyHeart, 0);
|
|
break;
|
|
|
|
case eMoney.Chat:
|
|
m_SaveData.MoneyChatCoin += add;
|
|
m_SaveData.MoneyChatCoin = Mathf.Max(m_SaveData.MoneyChatCoin, 0);
|
|
break;
|
|
|
|
case eMoney.Gacha:
|
|
m_SaveData.MoneyGacha += add;
|
|
m_SaveData.MoneyGacha = Mathf.Max(m_SaveData.MoneyGacha, 0);
|
|
break;
|
|
|
|
case eMoney.Lucky:
|
|
m_SaveData.MoneyLucky += add;
|
|
m_SaveData.MoneyLucky = Mathf.Max(m_SaveData.MoneyLucky, 0);
|
|
break;
|
|
|
|
case eMoney.MiniGameHP:
|
|
m_SaveData.MiniGameHP += add;
|
|
m_SaveData.MiniGameHP = Mathf.Max(m_SaveData.MiniGameHP, 0);
|
|
break;
|
|
|
|
//case eMoney.ItemBomb: m_SaveData.ItemBomb += add; m_SaveData.ItemBomb = Mathf.Max(m_SaveData.ItemBomb, 0); break;
|
|
//case eMoney.ItemUmbrella: m_SaveData.ItemUmbrella += add; m_SaveData.ItemUmbrella = Mathf.Max(m_SaveData.ItemUmbrella, 0); break;
|
|
//case eMoney.ItemDildo: m_SaveData.ItemDildo += add; m_SaveData.ItemDildo = Mathf.Max(m_SaveData.ItemDildo, 0); break;
|
|
}
|
|
|
|
LobbyUI.Ins.Set_Money();
|
|
}
|
|
|
|
public void Set_Money(eMoney money, int val)
|
|
{
|
|
switch (money)
|
|
{
|
|
case eMoney.AlbumOpen: m_SaveData.MoneyHeart = val; break;
|
|
case eMoney.Chat: m_SaveData.MoneyChatCoin = val; break;
|
|
case eMoney.Gacha: m_SaveData.MoneyGacha = val; break;
|
|
case eMoney.Lucky: m_SaveData.MoneyLucky = val; break;
|
|
case eMoney.MiniGameHP: m_SaveData.MiniGameHP = val; break;
|
|
//case eMoney.ItemBomb: m_SaveData.ItemBomb = val; break;
|
|
//case eMoney.ItemUmbrella: m_SaveData.ItemUmbrella = val; break;
|
|
//case eMoney.ItemDildo: m_SaveData.ItemDildo = val; 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;
|
|
case eMoney.MiniGameHP: return m_SaveData.MiniGameHP;
|
|
//case eMoney.ItemBomb: return m_SaveData.ItemBomb;
|
|
//case eMoney.ItemUmbrella: return m_SaveData.ItemUmbrella;
|
|
//case eMoney.ItemDildo: return m_SaveData.ItemDildo;
|
|
}
|
|
return 0;
|
|
}
|
|
public bool Check_Money(eMoney money, int amount, bool showToast = true)
|
|
{
|
|
var enough = Get_Money(money) >= amount;
|
|
if (!enough && showToast)
|
|
{
|
|
switch (money)
|
|
{
|
|
case eMoney.AlbumOpen:
|
|
LobbyUI.Ins.m_ToastUI.Set("하트가 부족합니다.");
|
|
break;
|
|
case eMoney.Chat:
|
|
LobbyUI.Ins.m_ToastUI.Set("채팅 코인이 부족합니다.");
|
|
break;
|
|
case eMoney.Gacha:
|
|
LobbyUI.Ins.m_ToastUI.Set("뽑기 재화가 부족합니다.");
|
|
break;
|
|
case eMoney.Lucky:
|
|
LobbyUI.Ins.m_ToastUI.Set("클로버가 부족합니다.");
|
|
break;
|
|
case eMoney.MiniGameHP:
|
|
case eMoney.ItemBomb:
|
|
case eMoney.ItemUmbrella:
|
|
case eMoney.ItemDildo:
|
|
LobbyUI.Ins.m_ToastUI.Set("재화가 부족합니다.");
|
|
break;
|
|
}
|
|
}
|
|
return enough;
|
|
}
|
|
|
|
public DateTime Get_MiniGameTime() { return m_SaveData.MiniGameHPTime; }
|
|
public void Set_MiniGameTime()
|
|
{
|
|
m_SaveData.MiniGameHPTime = InternetTime.Ins.Time.AddSeconds(table_GlobalValue.Ins.Get_Int("MiniGame_EnterMoney_Time"));
|
|
Save();
|
|
}
|
|
|
|
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 void Open_Image() { ++m_SaveData.GirlUnLockIndex; }
|
|
public int Get_UnLockIndex() { return m_SaveData.GirlUnLockIndex; }
|
|
public int Get_SelectGirlID() { return m_SaveData.SelectGirlID; }
|
|
public void Set_SelectGirlID(int id)
|
|
{
|
|
if (IsObtainGirl(id))
|
|
{
|
|
m_SaveData.SelectGirlID = id;
|
|
Save();
|
|
}
|
|
}
|
|
public bool IsObtainGirl(int id)
|
|
{
|
|
var pregirl = id - 1;
|
|
if (pregirl > 0)
|
|
{
|
|
var lst = table_album.Ins.Get_DataList(pregirl);
|
|
return lst.Count == Get_ImageCount(pregirl) && Get_ImageCount(id) > 0;
|
|
}
|
|
return true;
|
|
}
|
|
public int Get_ImageCount(int girlid)
|
|
{
|
|
var lst = table_album.Ins.Get_DataList(girlid);
|
|
var count = 0;
|
|
for (int i = 0; i < lst.Count; i++)
|
|
{
|
|
if (lst[i].n_Index <= Get_UnLockIndex())
|
|
++count;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
public bool CanShowGachaAD(bool showtoast = true)
|
|
{
|
|
var cal = m_SaveData.GachaADTime - InternetTime.Ins.Time;
|
|
var canshow = cal.TotalSeconds <= 0;
|
|
if (!canshow && showtoast) LobbyUI.Ins.m_ToastUI.Set($"{cal} 남음");
|
|
return canshow;
|
|
}
|
|
public void Add_GachaADTime(int sec)
|
|
{
|
|
m_SaveData.GachaADTime = InternetTime.Ins.Time.AddSeconds(sec);
|
|
Save();
|
|
}
|
|
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(shoptabledata data)
|
|
{
|
|
switch (data.e_InAppInitType)
|
|
{
|
|
default: if (data.b_AdRemove) return !m_SaveData.NoAD; else 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 void Set_ShopAD(bool noad)
|
|
{
|
|
if (!m_SaveData.NoAD)
|
|
{
|
|
m_SaveData.NoAD = noad;
|
|
ADInfo.Ins.Set_Banner(false);
|
|
SetBannerPos.Run();
|
|
}
|
|
}
|
|
public bool Get_ShopAD() { return m_SaveData.NoAD; }
|
|
|
|
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(); } }
|
|
ProtectedInt32 _MiniGameHP; public int MiniGameHP { get { return _MiniGameHP; } set { _MiniGameHP = value; _MiniGameHP.Obfuscate(); } }
|
|
//ProtectedInt32 _ItemBomb; public int ItemBomb { get { return _ItemBomb; } set { _ItemBomb = value; _ItemBomb.Obfuscate(); } }
|
|
//ProtectedInt32 _ItemUmbrella; public int ItemUmbrella { get { return _ItemUmbrella; } set { _ItemUmbrella = value; _ItemUmbrella.Obfuscate(); } }
|
|
//ProtectedInt32 _ItemDildo; public int ItemDildo { get { return _ItemDildo; } set { _ItemDildo = value; _ItemDildo.Obfuscate(); } }
|
|
|
|
ProtectedDateTime _MiniGameHPTime; public DateTime MiniGameHPTime { get { return _MiniGameHPTime; } set { _MiniGameHPTime = value; _MiniGameHPTime.Obfuscate(); } }
|
|
ProtectedDateTime _GachaADTime; public DateTime GachaADTime { get { return _GachaADTime; } set { _GachaADTime = value; _GachaADTime.Obfuscate(); } }
|
|
ProtectedDateTime _ShopADTime; public DateTime ShopADTime { get { return _ShopADTime; } set { _ShopADTime = value; _ShopADTime.Obfuscate(); } }
|
|
|
|
ProtectedBool _NoAD; public bool NoAD { get { return _NoAD; } set { _NoAD = value; _NoAD.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(); } }
|
|
}
|
|
} |