提交
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class SaveData
|
||||
{
|
||||
public static Saveobject saveobject;
|
||||
public static Saveobject GetSaveobject()
|
||||
{
|
||||
if (saveobject == null)
|
||||
{
|
||||
if (File.Exists(jsonFilePath))
|
||||
{
|
||||
string jsonstr = File.ReadAllText(jsonFilePath);
|
||||
saveobject = JsonConvert.DeserializeObject<Saveobject>(jsonstr);
|
||||
return saveobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveobject = new Saveobject();
|
||||
return saveobject;
|
||||
}
|
||||
}
|
||||
else return saveobject;
|
||||
|
||||
}
|
||||
|
||||
private static string jsonFilePath = Path.Combine(Application.persistentDataPath, "savedata22.json");
|
||||
|
||||
public static void saveDataFunc()
|
||||
{
|
||||
|
||||
if (saveobject == null) return;
|
||||
string save = JsonConvert.SerializeObject(saveobject);
|
||||
if (save == null || save == string.Empty) return;
|
||||
if (File.Exists(jsonFilePath)) File.Delete(jsonFilePath);
|
||||
File.WriteAllText(jsonFilePath, save);
|
||||
|
||||
}
|
||||
public static bool battlepassred()
|
||||
{
|
||||
|
||||
int pass_level = GameHelper.GetBattleLv();
|
||||
List<int> freelist = SaveData.GetSaveobject().battle_pass_freelist;
|
||||
for (int i = 1; i <= ConfigSystem.GetConfig<PassportrewardsModel>().dataList.Count; i++)
|
||||
{
|
||||
if (pass_level >= i)
|
||||
{
|
||||
if (!freelist.Contains(i))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (SaveData.GetSaveobject().is_get_battlepass)
|
||||
{
|
||||
List<int> paylist = SaveData.GetSaveobject().battle_pass_paylist;
|
||||
for (int i = 1; i <= ConfigSystem.GetConfig<PassportrewardsModel>().dataList.Count; i++)
|
||||
{
|
||||
if (pass_level >= i)
|
||||
{
|
||||
if (!paylist.Contains(i))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool passtaskred()
|
||||
{
|
||||
List<int> list = SaveData.GetSaveobject().pass_task_record;
|
||||
for (int i = 0; i < ConfigSystem.GetConfig<PassingTaskModel>().dataList.Count; i++)
|
||||
{
|
||||
if (GameHelper.GetLevel() > ConfigSystem.GetConfig<PassingTaskModel>().dataList[i].tol_num)
|
||||
{
|
||||
if (!list.Contains(ConfigSystem.GetConfig<PassingTaskModel>().dataList[i].id)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool timetaskred()
|
||||
{
|
||||
List<int> list = SaveData.GetSaveobject().time_task_record;
|
||||
for (int i = 0; i < ConfigSystem.GetConfig<DurationtasksModel>().dataList.Count; i++)
|
||||
{
|
||||
if (GameHelper.getGameTime() >= ConfigSystem.GetConfig<DurationtasksModel>().dataList[i].tol_num * 60)
|
||||
{
|
||||
if (!list.Contains(ConfigSystem.GetConfig<DurationtasksModel>().dataList[i].id)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool getRed()
|
||||
{
|
||||
|
||||
return battlepassred() || passtaskred() || timetaskred();
|
||||
}
|
||||
public static float pay_time = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class Saveobject
|
||||
{
|
||||
|
||||
|
||||
public bool is_get_battlepass = false;
|
||||
public List<int> battle_pass_freelist = new List<int>();
|
||||
public List<int> battle_pass_paylist = new List<int>();
|
||||
|
||||
|
||||
public long lastAdRewardExchangeTime;
|
||||
public int _goldtime0;
|
||||
public int _goldtime1;
|
||||
public int _goldtime2;
|
||||
public int _goldtime3;
|
||||
public int _goldtime4;
|
||||
public int _goldtime5;
|
||||
public int _goldtime6;
|
||||
public bool have_slot;
|
||||
public int battle_pass_time;
|
||||
|
||||
|
||||
public List<int> pass_task_record = new List<int>();
|
||||
public List<int> time_task_record = new List<int>();
|
||||
public int login_day;
|
||||
public int login_hour;
|
||||
public int cash_people;
|
||||
public float cash_people_1;
|
||||
public float cash_people_2;
|
||||
|
||||
public bool is_get_packreward;
|
||||
|
||||
public bool is_get_removead;
|
||||
public bool is_autopack_show;
|
||||
public int is_autopack_show_day;
|
||||
|
||||
public long start_time;
|
||||
public int clear_number;
|
||||
// public GooglePayClass google_pay_object = null;
|
||||
// public ApplePayClass apple_pay_object = null;
|
||||
public int this_time_cardtype;
|
||||
|
||||
public int[] dark_Dayref;
|
||||
|
||||
public RequestStageData StageData;
|
||||
public List<SaveingPotClass> saveingpot_history = new List<SaveingPotClass>();
|
||||
public float saveingpot_cash;
|
||||
public float last_saveingpot_cash;
|
||||
|
||||
public long failed_pack_time;
|
||||
public int three_gift_got_index = 1;
|
||||
public long last_got_three_gift_time = 0;
|
||||
public bool is_get_ThreeDaysGift;
|
||||
public ApplePayClass max_pay_object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0da9975597a8bc4a9989d80b46a72a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using ScrewsMaster;
|
||||
using UnityEngine;
|
||||
|
||||
public class SaveingPotClass
|
||||
{
|
||||
|
||||
public int tableId;
|
||||
|
||||
|
||||
public int id;
|
||||
|
||||
|
||||
public string amountStr;
|
||||
|
||||
|
||||
public float amount;
|
||||
|
||||
|
||||
public long makeupTime;
|
||||
|
||||
|
||||
public int videoCount;
|
||||
|
||||
|
||||
public int inlineInitNum;
|
||||
|
||||
|
||||
public int inlineNum;
|
||||
|
||||
|
||||
public string orderID;
|
||||
|
||||
|
||||
public SaveingPotTaskStatus status;
|
||||
|
||||
public long order_time = 0;
|
||||
public int WatchVideoSpeedNum = 0;
|
||||
public int loginSpeedNum = 0;
|
||||
public int activeMinute = 0;
|
||||
public int activeSpeedNum = 0;
|
||||
|
||||
public bool needShowAni = true;
|
||||
public float H5Time;
|
||||
|
||||
public long clear_time;
|
||||
public long start_time;
|
||||
public bool auto_show = false;
|
||||
public void SetStatus(SaveingPotTaskStatus _status)
|
||||
{
|
||||
status = _status;
|
||||
}
|
||||
|
||||
public string GetAmountStr()
|
||||
{
|
||||
// if (amount <= 0)
|
||||
// {
|
||||
// return amountStr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
return $"${amount:N}";
|
||||
//}
|
||||
}
|
||||
|
||||
public float cash_number = 0;
|
||||
}
|
||||
public enum SaveingPotTaskStatus
|
||||
{
|
||||
None,
|
||||
Task,
|
||||
Inline,
|
||||
}
|
||||
// var makeupTaskData = new MakeupTaskData();
|
||||
// makeupTaskData.tableId = makeupVo.id;
|
||||
// makeupTaskData.id = PreferencesMgr.Instance.MakeupTaskHistory.Count + 1;
|
||||
// makeupTaskData.amountStr = $"{GameHelper.Get102Str(makeupVo.item_need)}";
|
||||
// makeupTaskData.amount = makeupVo.item_need;
|
||||
// makeupTaskData.orderID = GameHelper.GetRandomNum(8);
|
||||
|
||||
// PreferencesMgr.Instance.MakeupTaskHistory.Add(makeupTaskData);
|
||||
// Debug.Log("uuuuuuuuuuuuuuuuuuuu");
|
||||
// makeupTaskData.SetStatus(MakeupTaskStatus.None);
|
||||
public class SaveingPotHelper
|
||||
{
|
||||
|
||||
public static void CheckSaveingPot()
|
||||
{
|
||||
Debug.Log(SaveData.GetSaveobject());
|
||||
if (SaveData.GetSaveobject().saveingpot_history == null || SaveData.GetSaveobject().saveingpot_history.Count == 0)
|
||||
{
|
||||
CreatSaveingPotItem();
|
||||
}
|
||||
ResetHistory();
|
||||
}
|
||||
|
||||
public static void CreatSaveingPotItem()
|
||||
{
|
||||
if (SaveData.GetSaveobject().saveingpot_history.Count >= 3)
|
||||
{
|
||||
SaveData.saveDataFunc();
|
||||
return;
|
||||
}
|
||||
int index = SaveData.GetSaveobject().saveingpot_history.Count;
|
||||
if (index >= ConfigSystem.GetConfig<MakeupModel_2>().dataList.Count) index = ConfigSystem.GetConfig<MakeupModel_2>().dataList.Count - 1;
|
||||
Makeup_2 config = ConfigSystem.GetConfig<MakeupModel_2>().dataList[index];
|
||||
SaveingPotClass saveingpot = new SaveingPotClass();
|
||||
saveingpot.tableId = config.id;
|
||||
saveingpot.id = SaveData.GetSaveobject().saveingpot_history.Count + 1;
|
||||
saveingpot.amountStr = $"${config.item_need:N}";
|
||||
saveingpot.amount = config.item_need;
|
||||
saveingpot.orderID = GameHelper.GetRandomNum(8);
|
||||
saveingpot.SetStatus(SaveingPotTaskStatus.None);
|
||||
saveingpot.clear_time = GameHelper.GetNowTime() + config.Reset_time * 3600;
|
||||
saveingpot.start_time = GameHelper.GetNowTime();
|
||||
|
||||
SaveData.GetSaveobject().saveingpot_history.Add(saveingpot);
|
||||
SaveData.saveDataFunc();
|
||||
Debug.Log("zengjaichenggong");
|
||||
}
|
||||
|
||||
public static bool TestingClearTime()
|
||||
{
|
||||
Debug.Log(SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].clear_time < GameHelper.GetNowTime());
|
||||
Debug.Log(SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].clear_time);
|
||||
Debug.Log(GameHelper.GetNowTime());
|
||||
if (SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].clear_time < GameHelper.GetNowTime() && SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].needShowAni)
|
||||
{
|
||||
Debug.Log("qinglisaveingpot");
|
||||
int index = SaveData.GetSaveobject().saveingpot_history.Count - 1;
|
||||
Makeup_2 config = ConfigSystem.GetConfig<MakeupModel_2>().dataList[index];
|
||||
SaveData.GetSaveobject().saveingpot_cash = 0;
|
||||
Debug.Log(JsonConvert.SerializeObject(config));
|
||||
Debug.Log(config.Reset_time);
|
||||
SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].clear_time = GameHelper.GetNowTime() + config.Reset_time * 3600;
|
||||
SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1].auto_show = false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static void ResetHistory()
|
||||
{
|
||||
for (int i = 0; i < SaveData.GetSaveobject().saveingpot_history.Count; i++)
|
||||
{
|
||||
SaveingPotClass saveingpot = SaveData.GetSaveobject().saveingpot_history[i];
|
||||
Makeup_2 config = ConfigSystem.GetConfig<MakeupModel_2>().dataList[i];
|
||||
saveingpot.amount = config.item_need;
|
||||
saveingpot.amountStr = $"${config.item_need:N}";
|
||||
if (saveingpot.start_time + config.Reset_time * 3600 - saveingpot.clear_time > 100)
|
||||
{
|
||||
saveingpot.clear_time = saveingpot.start_time + config.Reset_time * 3600;
|
||||
}
|
||||
}
|
||||
SaveData.saveDataFunc();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string getCashString(float cash)
|
||||
{
|
||||
return $"${cash:N}";
|
||||
}
|
||||
public static string getCashNumber(float cash)
|
||||
{
|
||||
return $"{cash:N}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 329120cf0ad8a4b6a9e4c56b36c62520
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user