提交项目
This commit is contained in:
@@ -0,0 +1,368 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
|
||||
public class ConfigSystem : BaseSystem
|
||||
{
|
||||
private static Dictionary<Type, object> configData = new Dictionary<Type, object>();
|
||||
public static List<GameUrls> light_weblist = new List<GameUrls>();
|
||||
public static List<GameUrls> dark_weblist = new List<GameUrls>();
|
||||
public static string web_through_str;
|
||||
public ConfigSystem(bool isAutoInit = true)
|
||||
{
|
||||
if (isAutoInit)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override void Init()
|
||||
{
|
||||
base.Init();
|
||||
AddListener();
|
||||
}
|
||||
|
||||
private void AddListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetConfig, OnRequestGetConfig);
|
||||
}
|
||||
|
||||
private void RemoveListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetConfig, OnRequestGetConfig);
|
||||
}
|
||||
|
||||
private void OnRequestGetConfig(object obj)
|
||||
{
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadBegin",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
|
||||
var loginData = GameHelper.GetLoginModel();
|
||||
|
||||
var configFileName = "JarvisConfigFile";
|
||||
var configFileSavePath = $"{ZooMatchFileKit.GetSavePath()}/Config/";
|
||||
var assetHotFixFilePath = $"{configFileSavePath}{configFileName}.txt";
|
||||
var configFileNameKey = "configFileName";
|
||||
var CDNConfigFileName = loginData.setting;
|
||||
|
||||
string savedCfgName = PlayerPrefs.GetString(configFileNameKey);
|
||||
bool needDownloadConfigFile = false;
|
||||
|
||||
if (!string.IsNullOrEmpty(CDNConfigFileName))
|
||||
{
|
||||
//如果本地Player Prefs里没有保存配置文件名
|
||||
if (string.IsNullOrEmpty(savedCfgName))
|
||||
{
|
||||
// Debug.Log("[UNITY] No config file name saved.");
|
||||
needDownloadConfigFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log($"[UNITY] Saved config name: {savedCfgName}, CDN config name: {CDNConfigFileName}");
|
||||
//与CDN上的对比名称
|
||||
if (!savedCfgName.Equals(CDNConfigFileName))
|
||||
{
|
||||
needDownloadConfigFile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Debug.Log($"[UNITY] needDownloadConfigFile: {needDownloadConfigFile}");
|
||||
//默默地拉去新配置
|
||||
if (needDownloadConfigFile)
|
||||
{
|
||||
CrazyAsyKit.StartCoroutine(DownloadKit.GetTextFromUrl($"{NetworkKit.CDNUrl}config/{CDNConfigFileName}",
|
||||
configFileName, (content) =>
|
||||
{
|
||||
PlayerPrefs.SetString(configFileNameKey, CDNConfigFileName);
|
||||
ParseConfig(content);
|
||||
|
||||
}, configFileSavePath));
|
||||
}
|
||||
//检查设备本地是否有配置文件
|
||||
if (File.Exists(assetHotFixFilePath))
|
||||
{
|
||||
Debug.Log($"[UNITY] Load config from datapath: {assetHotFixFilePath}");
|
||||
ParseConfig(File.ReadAllText(assetHotFixFilePath));
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
|
||||
|
||||
}
|
||||
else //没有就从StreamingAssets读取
|
||||
{
|
||||
var path = $"{Application.streamingAssetsPath}/Config/{configFileName}.txt";
|
||||
#if UNITY_IOS
|
||||
path = "file://" + path;
|
||||
#endif
|
||||
Debug.Log($"[UNITY] Load config from streaming asset: {path}");
|
||||
CrazyAsyKit.StartCoroutine(DownloadKit.GetTextFromUrl(path, configFileName, content =>
|
||||
{
|
||||
//if (string.IsNullOrEmpty(content))
|
||||
Debug.Log("[Unity]content is empty ");
|
||||
|
||||
ParseConfig(content);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
SaveingPotHelper.ResetHistory();
|
||||
}, configFileSavePath));
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseConfig(string json)
|
||||
{
|
||||
if (json == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!json.StartsWith("{"))
|
||||
{
|
||||
json = Base64Kit.Decode(json,NetworkManager.identifier);
|
||||
}
|
||||
|
||||
var dictionary = SerializeUtil.ToObject<Dictionary<string, object>>(json);
|
||||
ParseGameConfig(dictionary);
|
||||
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartBefore);
|
||||
|
||||
var reqData1 = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadFinish",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData1);
|
||||
}
|
||||
|
||||
#region 游戏配置
|
||||
|
||||
private void ParseGameConfig(IReadOnlyDictionary<string, object> dictionary)
|
||||
{
|
||||
if (dictionary.TryGetValue("Common", out var common))
|
||||
{
|
||||
var commonModel = SerializeUtil.ToObject<CommonModel>(common.ToString());
|
||||
configData[typeof(CommonModel)] = commonModel;
|
||||
}
|
||||
|
||||
var GameConfigModel = new GameConfigModel();
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
if (item.Key.StartsWith("GameBoard"))
|
||||
{
|
||||
string[] parts = item.Key.Split('_');
|
||||
|
||||
int boardIndex;
|
||||
if (parts.Length > 1 && int.TryParse(parts[1], out boardIndex))
|
||||
{
|
||||
// 成功解析出数字
|
||||
// Debug.Log($"boardIndex==== {boardIndex}");
|
||||
}
|
||||
else
|
||||
{
|
||||
boardIndex = 1;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue(item.Key, out var gameboard))
|
||||
{
|
||||
|
||||
if(!GameConfigModel.game_conf.ContainsKey(boardIndex))
|
||||
{
|
||||
GameConfigModel.game_conf.Add(boardIndex, null);
|
||||
}
|
||||
|
||||
GameConfigModel.game_conf[boardIndex] = SerializeUtil.ToObject<List<GameBoard>>(gameboard.ToString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
configData[typeof(GameConfigModel)] = GameConfigModel;
|
||||
|
||||
if (dictionary.TryGetValue("SignDailyReward", out var signDailyReward))
|
||||
{
|
||||
var signDailyRewardModel = new SignDailyRewardModel();
|
||||
|
||||
signDailyRewardModel.dataList = SerializeUtil.ToObject<List<SignDailyReward>>(signDailyReward.ToString());
|
||||
|
||||
configData[typeof(SignDailyRewardModel)] = signDailyRewardModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("turntable", out var turntable))
|
||||
{
|
||||
var turntableModel = new TurntableModel();
|
||||
turntableModel.dataList = SerializeUtil.ToObject<List<Turntable>>(turntable.ToString());
|
||||
configData[typeof(TurntableModel)] = turntableModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("rewardNum", out var rewardNum))
|
||||
{
|
||||
var rewardNumModel = new RewardNumModel();
|
||||
rewardNumModel.dataList = SerializeUtil.ToObject<List<RewardNum>>(rewardNum.ToString());
|
||||
configData[typeof(RewardNumModel)] = rewardNumModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("Durationtasks", out var durationtasks))
|
||||
{
|
||||
var DurationtasksModel = new DurationtasksModel();
|
||||
DurationtasksModel.dataList = SerializeUtil.ToObject<List<Durationtasks>>(durationtasks.ToString());
|
||||
configData[typeof(DurationtasksModel)] = DurationtasksModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("PassingTasks", out var passingtask))
|
||||
{
|
||||
var PassingTaskModel = new PassingTaskModel();
|
||||
PassingTaskModel.dataList = SerializeUtil.ToObject<List<PassingTask>>(passingtask.ToString());
|
||||
configData[typeof(PassingTaskModel)] = PassingTaskModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("ADTasks", out var adtask))
|
||||
{
|
||||
var ADTaskModel = new ADTaskModel();
|
||||
ADTaskModel.dataList = SerializeUtil.ToObject<List<ADTask>>(adtask.ToString());
|
||||
configData[typeof(ADTaskModel)] = ADTaskModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("Passportrewards", out var Passportrewards))
|
||||
{
|
||||
var PassportrewardsModel = new PassportrewardsModel();
|
||||
PassportrewardsModel.dataList = SerializeUtil.ToObject<List<Passportrewards>>(Passportrewards.ToString());
|
||||
configData[typeof(PassportrewardsModel)] = PassportrewardsModel;
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("SmallrewardNum", out var SmallrewardNum))
|
||||
{
|
||||
var SmallrewardNumModel = new SmallrewardNumModel();
|
||||
SmallrewardNumModel.dataList = SerializeUtil.ToObject<List<SmallrewardNum>>(SmallrewardNum.ToString());
|
||||
configData[typeof(SmallrewardNumModel)] = SmallrewardNumModel;
|
||||
// Debug.Log(SmallrewardNum.ToString());
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("LargerewardNum", out var LargerewardNum))
|
||||
{
|
||||
var LargerewardNumModel = new LargerewardNumModel();
|
||||
LargerewardNumModel.dataList = SerializeUtil.ToObject<List<LargerewardNum>>(LargerewardNum.ToString());
|
||||
configData[typeof(LargerewardNumModel)] = LargerewardNumModel;
|
||||
// Debug.Log(LargerewardNum.ToString());
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("exBrPool", out var exBrPool))
|
||||
{
|
||||
var exBrPoolModel = new exBrPoolModel();
|
||||
exBrPoolModel.dataList = SerializeUtil.ToObject<List<exBrPool>>(exBrPool.ToString());
|
||||
configData[typeof(exBrPoolModel)] = exBrPoolModel;
|
||||
ConfigSystem.GetConfig<exBrPoolModel>().config_name_list = ConfigSystem.GetConfig<exBrPoolModel>().dataList[0].user_name.Split(",").ToList();
|
||||
ConfigSystem.GetConfig<exBrPoolModel>().config_money_list = ConfigSystem.GetConfig<exBrPoolModel>().dataList[0].amount.Split(",").ToList();
|
||||
}
|
||||
if (dictionary.TryGetValue("exBrPool_2", out var exBrPool_2))
|
||||
{
|
||||
var exBrPoolModel_2 = new exBrPoolModel_2
|
||||
{ dataList = SerializeUtil.ToObject<List<exBrPool_2>>(exBrPool_2.ToString()) };
|
||||
configData[typeof(exBrPoolModel_2)] = exBrPoolModel_2;
|
||||
ConfigSystem.GetConfig<exBrPoolModel_2>().config_name_list = ConfigSystem.GetConfig<exBrPoolModel_2>().dataList[0].user_name.Split(",").ToList();
|
||||
ConfigSystem.GetConfig<exBrPoolModel_2>().config_money_list = ConfigSystem.GetConfig<exBrPoolModel_2>().dataList[0].amount.Split(",").ToList();
|
||||
}
|
||||
if (dictionary.TryGetValue("makeup", out var makeup))
|
||||
{
|
||||
var makeupModel = new MakeupModel
|
||||
{ dataList = SerializeUtil.ToObject<List<Makeup>>(makeup.ToString()) };
|
||||
configData[typeof(MakeupModel)] = makeupModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("makeup_2", out var makeup_2))
|
||||
{
|
||||
var makeupModel_2 = new MakeupModel_2
|
||||
{ dataList = SerializeUtil.ToObject<List<Makeup_2>>(makeup_2.ToString()) };
|
||||
Debug.Log("---------------" + makeup_2.ToString());
|
||||
configData[typeof(MakeupModel_2)] = makeupModel_2;
|
||||
}
|
||||
if (dictionary.TryGetValue("GameUrls", out var GameUrls))
|
||||
{
|
||||
light_weblist.Clear();
|
||||
dark_weblist.Clear();
|
||||
web_through_str = "";
|
||||
|
||||
List<GameUrls> alllist = new List<GameUrls>();
|
||||
alllist = SerializeUtil.ToObject<List<GameUrls>>(GameUrls.ToString());
|
||||
List<int> type_list = new List<int>();
|
||||
for (int i = 0; i < alllist.Count; i++)
|
||||
{
|
||||
if (alllist[i].webType == 2)
|
||||
{
|
||||
if (GameHelper.IsGiftSwitch() && (alllist[i].isMagic == 1)) light_weblist.Add(alllist[i]);
|
||||
else if (!GameHelper.IsGiftSwitch() && (alllist[i].isMagic == 0)) light_weblist.Add(alllist[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
dark_weblist.Add(alllist[i]);
|
||||
if (!type_list.Contains(alllist[i].wvType))
|
||||
{
|
||||
web_through_str += alllist[i].wvthrough;
|
||||
web_through_str += "|";
|
||||
type_list.Add(alllist[i].wvType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
web_through_str.Remove(web_through_str.Length - 1);
|
||||
|
||||
var gameUrlsModel = new GameUrlsModel
|
||||
{
|
||||
dataList = light_weblist
|
||||
};
|
||||
configData[typeof(GameUrlsModel)] = gameUrlsModel;
|
||||
}
|
||||
Debug.Log(GameUrls);
|
||||
if (dictionary.TryGetValue("Paidcoins", out var Paidcoins))
|
||||
{
|
||||
var PaidcoinsModel = new PaidcoinsModel
|
||||
{ dataList = SerializeUtil.ToObject<List<Paidcoins>>(Paidcoins.ToString()) };
|
||||
configData[typeof(PaidcoinsModel)] = PaidcoinsModel;
|
||||
// Debug.Log(Paidcoins.ToString());
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("Paidgift", out var Paidgift))
|
||||
{
|
||||
var PaidgiftModel = new PaidgiftModel
|
||||
{ dataList = SerializeUtil.ToObject<List<Paidgift>>(Paidgift.ToString()) };
|
||||
configData[typeof(PaidgiftModel)] = PaidgiftModel;
|
||||
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue("OnlineRewards", out var OnlineRewards))
|
||||
{
|
||||
var OnlineRewardsModel = new OnlineRewardsModel
|
||||
{ dataList = SerializeUtil.ToObject<List<OnlineRewards>>(OnlineRewards.ToString()) };
|
||||
configData[typeof(OnlineRewardsModel)] = OnlineRewardsModel;
|
||||
|
||||
}
|
||||
if (dictionary.TryGetValue("Multigift", out var Multigift))
|
||||
{
|
||||
var MultigiftModel = new MultigiftModel
|
||||
{ dataList = SerializeUtil.ToObject<List<Multigift>>(Multigift.ToString()) };
|
||||
configData[typeof(MultigiftModel)] = MultigiftModel;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static T GetConfig<T>()
|
||||
{
|
||||
return configData.TryGetValue(typeof(T), out var value) ? (T)value : default;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
RemoveListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a3bd721f95842948573aea8599cd364
|
||||
timeCreated: 1692603665
|
||||
@@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
|
||||
public class LoginSystem : BaseSystem
|
||||
{
|
||||
|
||||
private int loginCount = 0;
|
||||
public LoginSystem(bool isAutoInit = true)
|
||||
{
|
||||
if (isAutoInit)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override void Init()
|
||||
{
|
||||
base.Init();
|
||||
InitData();
|
||||
AddListener();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
}
|
||||
|
||||
private void AddListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.Login, RequestLogin);
|
||||
}
|
||||
|
||||
private void RemoveListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.Login, RequestLogin);
|
||||
}
|
||||
|
||||
private TimerTask timerTask = null;
|
||||
private void RequestLogin(object obj = null)
|
||||
{
|
||||
|
||||
Debug.Log($"barry attribution: {SuperApplication.Instance.attribution}");
|
||||
var requestLoginData = new RequestLoginData
|
||||
{
|
||||
device_id = SystemInfo.deviceUniqueIdentifier,
|
||||
pack_name = NetworkManager.identifier,
|
||||
app_version = Application.version,
|
||||
//is debug test--------
|
||||
channel = SuperApplication.Instance.attribution,
|
||||
sim = NetworkManager.haveSimCard
|
||||
|
||||
};
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginSend",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
NetworkKit.Post<LoginModel>("login", requestLoginData, (isSuccess, loginData) =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
var loginModel = GameHelper.GetLoginModel();
|
||||
loginModel.cdn_url = loginData.cdn_url;
|
||||
loginModel.setting = loginData.setting;
|
||||
loginModel.play_data = loginData.play_data;
|
||||
loginModel.token = loginData.token;
|
||||
loginModel.uid = loginData.uid;
|
||||
loginModel.country = loginData.country;
|
||||
loginModel.expires_at = loginData.expires_at;
|
||||
loginModel.invite_code = loginData.invite_code;
|
||||
loginModel.invite_url = loginData.invite_url;
|
||||
loginModel.is_magic = loginData.is_magic;
|
||||
loginModel.last_login_time = loginData.last_login_time;
|
||||
loginModel.login_time = loginData.login_time;
|
||||
loginModel.reg_time = loginData.reg_time;
|
||||
loginModel.new_player = loginData.new_player;
|
||||
loginModel.play_data_ver = loginData.play_data_ver;
|
||||
loginModel.enwp = loginData.enwp;
|
||||
loginModel.debug_log = loginData.debug_log;
|
||||
|
||||
loginModel.preferences = new Preferences();
|
||||
NetworkKit.CDNUrl = $"{loginData.cdn_url}/";
|
||||
NetworkKit.userId = loginData.uid;
|
||||
NetworkKit.SetCacheToken(loginData.token);
|
||||
DateTimeManager.Instance.SetServerCurrTimestamp(loginData.login_time);
|
||||
RequestHeart();
|
||||
|
||||
if (timerTask == null)
|
||||
{
|
||||
// Debug.Log("$ timer task fuzhi---------");
|
||||
timerTask = TimerHelper.UnscaleGeneral.AddLoopTimer(60, (timer) => { RequestHeart(); });
|
||||
}
|
||||
|
||||
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetPlayData);
|
||||
MaxADKit.SetUserID(loginData.uid.ToString());
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginRecv",
|
||||
payload = "success"
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
|
||||
// if (loginData.new_player)
|
||||
// {
|
||||
// AdjustEvent adjustEvent = new AdjustEvent("sasxod");
|
||||
// Adjust.TrackEvent(adjustEvent);
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginRecv",
|
||||
payload = "fail"
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
|
||||
float times = loginCount == 0 ? 0 : 5f;
|
||||
|
||||
DOVirtual.DelayedCall(times,()=>{
|
||||
if (loginCount < 5) {
|
||||
loginCount++;
|
||||
RequestLogin();
|
||||
|
||||
} else {
|
||||
loginCount = 0;
|
||||
Action _OnFail = () =>
|
||||
{
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
};
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, _OnFail);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void RequestHeart()
|
||||
{
|
||||
NetworkKit.PostWithHeader("user/health");
|
||||
|
||||
// Debug.Log($"barry 心跳: ---------");
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
RemoveListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e448e373b1b484b8918ec80a7f28448
|
||||
timeCreated: 1692267393
|
||||
@@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class PlayDataSystem : BaseSystem
|
||||
{
|
||||
public PlayDataSystem(bool isAutoInit = true)
|
||||
{
|
||||
if (isAutoInit)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
AddListener();
|
||||
}
|
||||
|
||||
private void AddListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetPlayData, OnRequestPlayData);
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
|
||||
}
|
||||
|
||||
private void RemoveListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetPlayData, OnRequestPlayData);
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
|
||||
}
|
||||
|
||||
private void OnRequestPlayData(object args)
|
||||
{
|
||||
NetworkKit.PostWithHeader<Preferences>("user/userData", (isSuccess, obj) =>
|
||||
{
|
||||
var loginModel = GameHelper.GetLoginModel();
|
||||
loginModel.preferences = obj;
|
||||
|
||||
PreferencesMgr.Instance.InitPreferences();
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
|
||||
});
|
||||
}
|
||||
|
||||
private void OnRequestSavePlayData(object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
var msg = obj as Dictionary<string, object>;
|
||||
|
||||
if (msg == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var version = 1L;
|
||||
if (msg.TryGetValue("data_ver", out var ver))
|
||||
{
|
||||
if (version != default)
|
||||
{
|
||||
version = (long)ver;
|
||||
}
|
||||
}
|
||||
|
||||
var data = SerializeUtil.ToJson<Dictionary<string, object>>(msg);
|
||||
|
||||
var requestData = new RequestSavePlayData
|
||||
{
|
||||
version = version,
|
||||
data = data
|
||||
};
|
||||
// NetworkKit.PostWithHeader("user/updateData", requestData);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
RemoveListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b2141f8f0f64581b0f291d0ca27ece2
|
||||
timeCreated: 1692343794
|
||||
Reference in New Issue
Block a user