Files
CaptainDiceDubloons_IOS_unity/Assets/Scripts/DataMgr/DataMgr.cs
T
2026-05-25 15:06:47 +08:00

86 lines
4.7 KiB
C#

using System.Collections.Generic;
using System.Diagnostics;
using Assets.Scripts;
using ChillConnect;
using IgnoreOPS;
using SGModule.DataStorage;
public static partial class DataMgr
{
public static string long_name;
public static string short_name;
private static DataStorage<T> BindDataStorage<T>(string key, string messageKey = null, T @default = default)
{
return new DataStorage<T>(key, @default, (oldValue, newValue) =>
{
// 构造 ChangeValue 对象
if (messageKey == DataKeys.signState)
{
int a = 0;
}
var changeValue = new ChangeValue<T>
{
oldValue = oldValue,
newValue = newValue
};
if (messageKey.IsNullOrWhiteSpace())
{
return;
}
// 调用特定类型的分发器
PreferencesDispatcher<T>.Instance.Dispatch(messageKey, changeValue);
// 调用全局数据分发器(如果需要)
DataDispatcher.Instance.Dispatch(messageKey);
});
}
#region ValueType
public static DataStorage<bool> FirstLogin = new(DataKeys.FirstLogin, true);
public static DataStorage<long> UserID = BindDataStorage(DataKeys.UserID, @default: -1L);
public static DataStorage<long> NextOpenWheelStampTime = BindDataStorage<long>(DataKeys.nextOpenWheelStampTime);
public static DataStorage<int> ThisDayWatchSlyderVideoNum = BindDataStorage<int>(DataKeys.thisDayWatchSlyderVideoNum);
public static DataStorage<int> Coin = BindDataStorage<int>(DataKeys.currency101, DataMsg.currency101);
public static DataStorage<decimal> Ticket = BindDataStorage<decimal>(DataKeys.currency102, DataMsg.currency102);
public static DataStorage<int> MaxCurrency101 = BindDataStorage<int>(DataKeys.maxCurrency101);
public static DataStorage<string> PlayerName = BindDataStorage<string>(DataKeys.playerName, DataMsg.playerName);
public static DataStorage<int> PlayerAvatarId = BindDataStorage<int>(DataKeys.playerAvatarId, DataMsg.playerAvatarId);
public static DataStorage<int> GameOfCount = BindDataStorage<int>(DataKeys.gameOfCount);
public static DataStorage<int> GameLevel = BindDataStorage(DataKeys.gameLevel, @default: 1);
public static DataStorage<string> ExchangeAccount = BindDataStorage<string>(DataKeys.exchangeAccount);
public static DataStorage<string> ExchangeName = BindDataStorage<string>(DataKeys.exchangeName);
public static DataStorage<bool> IsShowRewardFly101 = BindDataStorage<bool>(DataKeys.isShowRewardFly101, DataMsg.isShowRewardFly101);
public static DataStorage<bool> IsShowRewardFly102 = BindDataStorage<bool>(DataKeys.isShowRewardFly102);
public static DataStorage<decimal> PlayReawrd111 = BindDataStorage<decimal>(DataKeys.playReawrd111, DataMsg.playReawrd111);
public static DataStorage<bool> IsShowRewardFly111 = BindDataStorage<bool>(DataKeys.isShowRewardFly111, DataMsg.isShowRewardFly111);
public static DataStorage<bool> IsShowOpenReward = BindDataStorage<bool>(DataKeys.isShowOpenReward);
public static DataStorage<bool> IsLastH5Tab = BindDataStorage<bool>(DataKeys.isLastH5Tab);
public static DataStorage<long> AdCashFlyShowTime = BindDataStorage<long>(DataKeys.adCashFlyShowTime);
public static DataStorage<int> H5StayTime = BindDataStorage<int>(DataKeys.h5StayTime);
public static DataStorage<int> VideoWatchCount = BindDataStorage<int>(DataKeys.videoWatchCount);
public static DataStorage<decimal> MakeupTaskH5Time = BindDataStorage<decimal>(DataKeys.makeupTaskH5Time);
public static DataStorage<int> GameStartCount = BindDataStorage<int>(DataKeys.gameStartCount);
public static DataStorage<int> LoginGameTodayTimes = BindDataStorage<int>(DataKeys.loginGameTodayTimes);
public static DataStorage<string> Date = BindDataStorage<string>(DataKeys.date);
public static DataStorage<int> ChLevel = BindDataStorage<int>(DataKeys.ch_level);
public static DataStorage<string> LevelData = new(DataKeys.LevelData, cloudSave: false);
public static DataStorage<int> AvailableDiceRolls = BindDataStorage<int>(DataKeys.AvailableDiceRolls);
#endregion
#region RefType
public static DataStorage<List<long>> SignState = BindDataStorage(DataKeys.signState, @default: new List<long>());
public static DataStorage<List<MakeupTaskData>> MakeupTaskHistory = BindDataStorage(DataKeys.makeupTaskHistory, @default: new List<MakeupTaskData>());
public static DataStorage<Saveobject> SaveObject = BindDataStorage(DataKeys.SaveObject, @default: new Saveobject());
public static DataStorage<List<string>> ApplePayTransactionID = BindDataStorage(DataKeys.ApplePayTransactionID, @default: new List<string>());
#endregion
}