fix:1、更换项目,使用winter来创建
This commit is contained in:
@@ -1,473 +1,122 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.Common.Helper;
|
||||
using SGModule.ConfigLoader;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
{
|
||||
|
||||
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>();
|
||||
namespace LoveLegend {
|
||||
public class ConfigSystem : BaseSystem {
|
||||
public static string web_through_str;
|
||||
public static int requestConfigType = 0;
|
||||
public ConfigSystem(bool isAutoInit = true)
|
||||
{
|
||||
if (isAutoInit)
|
||||
{
|
||||
|
||||
public ConfigSystem(bool isAutoInit = true) {
|
||||
if (isAutoInit) {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override void Init()
|
||||
{
|
||||
public sealed override void Init() {
|
||||
base.Init();
|
||||
AddListener();
|
||||
}
|
||||
|
||||
private void AddListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetConfig, OnRequestGetConfig);
|
||||
private void AddListener() {
|
||||
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetConfig, OnGetConfig);
|
||||
}
|
||||
|
||||
private void RemoveListener()
|
||||
{
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetConfig, OnRequestGetConfig);
|
||||
private void RemoveListener() {
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetConfig, OnGetConfig);
|
||||
}
|
||||
|
||||
private void OnRequestGetConfig(object obj)
|
||||
{
|
||||
private void OnGetConfig(object obj) {
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoadBegin); //加载开始打点
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadBegin",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
if (obj != null) requestConfigType = (int)obj;
|
||||
|
||||
|
||||
var loginData = GameHelper.GetLoginModel();
|
||||
|
||||
var configFileName = "JarvisConfigFile";
|
||||
var configFileSavePath = $"{GemCrushFileKit.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;
|
||||
var loginModel = LoginKit.Instance.LoginModel;
|
||||
ConfigLoader.Instance.Init(new ConfigInitOptions {
|
||||
Setting = loginModel.Setting,
|
||||
CdnUrl = loginModel.CdnURL,
|
||||
OnComplete = state => {
|
||||
Debug.Log($"配置加载状态{state}");
|
||||
if (state == ConfigLoaderState.Successful) {
|
||||
ReloadConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[UNITY] needDownloadConfigFile: {needDownloadConfigFile}");
|
||||
//默默地拉去新配置
|
||||
if (needDownloadConfigFile)
|
||||
{
|
||||
CrazyAsyKit.StartCoroutine(DownloadKit.GetTextFromUrl($"{NetworkKit.CDNUrl}config/{CDNConfigFileName}",
|
||||
configFileName, (content) =>
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
Debug.Log("down config error");
|
||||
loadLocalConfig(assetHotFixFilePath, configFileName, configFileSavePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("down config success");
|
||||
PlayerPrefs.SetString(configFileNameKey, CDNConfigFileName);
|
||||
ParseConfig(content);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadFinish",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
}
|
||||
SaveingPotHelper.ResetHistory();
|
||||
}, configFileSavePath));
|
||||
}
|
||||
else
|
||||
{
|
||||
loadLocalConfig(assetHotFixFilePath, configFileName, configFileSavePath);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLocalConfig(string assetHotFixFilePath, string configFileName, string configFileSavePath)
|
||||
{
|
||||
if (File.Exists(assetHotFixFilePath))
|
||||
{
|
||||
ParseConfig(File.ReadAllText(assetHotFixFilePath));
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadFinish",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
ParseConfig(content);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadFinish",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
}, configFileSavePath));
|
||||
}
|
||||
},
|
||||
OnError = (errorName, message) => {
|
||||
Debug.LogError($"配置解析错误 {errorName} 错误信息:{message}");
|
||||
},
|
||||
OnHandleUnmarkedConfig = ParseGameConfig
|
||||
});
|
||||
}
|
||||
|
||||
private void ParseConfig(string json)
|
||||
{
|
||||
if (json == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!json.StartsWith("{"))
|
||||
{
|
||||
json = Base64Kit.Decode(json, NetworkManager.identifier);
|
||||
}
|
||||
/// <summary>
|
||||
/// 重新加载配置
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
private void ReloadConfig() {
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoadFinish); //加载完成打点
|
||||
|
||||
var dictionary = SerializeUtil.ToObject<Dictionary<string, object>>(json);
|
||||
ParseGameConfig(dictionary);
|
||||
TextureHelper.imgUrl = LoginKit.Instance.LoginModel.CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
||||
LiveVideoManager.videoBaseUrl = LoginKit.Instance.LoginModel.CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
||||
|
||||
// ParseGameConfig();
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartBefore);
|
||||
|
||||
if (requestConfigType == 0)
|
||||
{
|
||||
// Debug.Log("NeedShowOpenAd----0-");
|
||||
if (GameHelper.NeedShowOpenAd())
|
||||
{
|
||||
Debug.Log("NeedShowOpenAd----0-");
|
||||
GameHelper.ShowOpenAd();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.CloseMask);
|
||||
}
|
||||
}
|
||||
|
||||
var reqData1 = new RespLoginFunnelData
|
||||
{
|
||||
type = "loadFinish",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData1);
|
||||
SaveingPotHelper.ResetHistory();
|
||||
}
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
private void ParseGameConfig() {
|
||||
var gameConfigModel = new GameConfigModel();
|
||||
foreach (var key in ConfigLoader.Instance.GetJsonKeys()) {
|
||||
if (!key.StartsWith("GameBoard")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var GameConfigModel = new GameConfigModel();
|
||||
// 提取 boardIndex
|
||||
var boardIndex = 1;
|
||||
var parts = key.Split('_');
|
||||
if (parts.Length > 1 && int.TryParse(parts[1], out var parsed)) {
|
||||
boardIndex = parsed;
|
||||
}
|
||||
|
||||
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);
|
||||
// 获取 json 并反序列化
|
||||
if (ConfigLoader.Instance.TryGetJsonValue(key, out var gameboardJson)) {
|
||||
try {
|
||||
var gameBoards = gameboardJson.As<List<GameBoard>>();
|
||||
if (gameBoards != null) {
|
||||
gameConfigModel.game_conf[boardIndex] = gameBoards;
|
||||
}
|
||||
|
||||
GameConfigModel.game_conf[boardIndex] = SerializeUtil.ToObject<List<GameBoard>>(gameboard.ToString());
|
||||
|
||||
else {
|
||||
Log.ConfigLoader.Warning($"GameBoard 配置 {key} 反序列化为空");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.ConfigLoader.Error($"GameBoard 配置 {key} 反序列化失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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("Multigift", out var Multigift))
|
||||
{
|
||||
var MultigiftModel = new MultigiftModel
|
||||
{ dataList = SerializeUtil.ToObject<List<Multigift>>(Multigift.ToString()) };
|
||||
configData[typeof(MultigiftModel)] = MultigiftModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("FAQRule", out var FAQRule))
|
||||
{
|
||||
var FaqModel = new FAQRuleModel
|
||||
{ dataList = SerializeUtil.ToObject<List<FAQRule>>(FAQRule.ToString()) };
|
||||
configData[typeof(FAQRuleModel)] = FaqModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("FAQRule_1", out var FAQRule_1))
|
||||
{
|
||||
var FaqModel = new FAQRuleModel_1
|
||||
{ dataList = SerializeUtil.ToObject<List<FAQRule>>(FAQRule_1.ToString()) };
|
||||
configData[typeof(FAQRuleModel_1)] = FaqModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("MessageBoard", out var MessageBoard))
|
||||
{
|
||||
var messageModel = new MessageBoardModel
|
||||
{ dataList = SerializeUtil.ToObject<List<MessageBoard>>(MessageBoard.ToString()) };
|
||||
configData[typeof(MessageBoardModel)] = messageModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("MessageBoard_1", out var MessageBoard_1))
|
||||
{
|
||||
var messageModel = new MessageBoardModel_1
|
||||
{ dataList = SerializeUtil.ToObject<List<MessageBoard>>(MessageBoard_1.ToString()) };
|
||||
configData[typeof(MessageBoardModel_1)] = messageModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("RankHourRewards", out var RankHourRewards))
|
||||
{
|
||||
var RankHourRewardsModel = new RankHourRewardsModel();
|
||||
RankHourRewardsModel.dataList = SerializeUtil.ToObject<List<RankRewards>>(RankHourRewards.ToString());
|
||||
configData[typeof(RankHourRewardsModel)] = RankHourRewardsModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("RankDayRewards", out var RankDayRewards))
|
||||
{
|
||||
var RankDayRewardsModel = new RankDayRewardsModel();
|
||||
RankDayRewardsModel.dataList = SerializeUtil.ToObject<List<RankRewards>>(RankDayRewards.ToString());
|
||||
configData[typeof(RankDayRewardsModel)] = RankDayRewardsModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("RankWeekRewards", out var RankWeekRewards))
|
||||
{
|
||||
var RankWeekRewardsModel = new RankWeekRewardsModel();
|
||||
RankWeekRewardsModel.dataList = SerializeUtil.ToObject<List<RankRewards>>(RankWeekRewards.ToString());
|
||||
configData[typeof(RankWeekRewardsModel)] = RankWeekRewardsModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("TurnOffRewards", out var TurnOffRewards))
|
||||
{
|
||||
var TurnOffRewardsModel = new TurnOffRewardsModel();
|
||||
TurnOffRewardsModel.dataList = SerializeUtil.ToObject<List<TurnOffRewards>>(TurnOffRewards.ToString());
|
||||
configData[typeof(TurnOffRewardsModel)] = TurnOffRewardsModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("LevelAttempts", out var LevelAttempts))
|
||||
{
|
||||
var LevelAttemptsModel = new LevelAttemptsModel();
|
||||
LevelAttemptsModel.dataList = SerializeUtil.ToObject<List<LevelAttempts>>(LevelAttempts.ToString());
|
||||
configData[typeof(LevelAttemptsModel)] = LevelAttemptsModel;
|
||||
ConfigSystem.GetConfig<LevelAttemptsModel>().config_name_list = ConfigSystem.GetConfig<LevelAttemptsModel>().dataList[0].user_name.Split(",").ToList();
|
||||
ConfigSystem.GetConfig<LevelAttemptsModel>().config_money_list = ConfigSystem.GetConfig<LevelAttemptsModel>().dataList[0].amount.Split(",").ToList();
|
||||
}
|
||||
if (dictionary.TryGetValue("ExchangeDescriptors", out var ExchangeDescriptors))
|
||||
{
|
||||
var ExchangeDesModel = new ExchangeDesModel();
|
||||
ExchangeDesModel.dataList = SerializeUtil.ToObject<List<ExchangeDes>>(ExchangeDescriptors.ToString());
|
||||
configData[typeof(ExchangeDesModel)] = ExchangeDesModel;
|
||||
}
|
||||
if (dictionary.TryGetValue("SplashAD", out var SplashAD))
|
||||
{
|
||||
var AppOpenAdModel = new AppOpenAdModel();
|
||||
AppOpenAdModel.dataList = SerializeUtil.ToObject<List<SplashAD>>(SplashAD.ToString());
|
||||
configData[typeof(AppOpenAdModel)] = AppOpenAdModel;
|
||||
}
|
||||
ConfigLoader.Instance.AddConfig(gameConfigModel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static T GetConfig<T>()
|
||||
{
|
||||
return configData.TryGetValue(typeof(T), out var value) ? (T)value : default;
|
||||
public static CommonModel GetCommonConf() {
|
||||
return ConfigLoader.Instance.GetConfig<CommonModel>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
public static List<T> GetConfig<T>() where T : class {
|
||||
return ConfigLoader.Instance.GetConfig<List<T>>() ?? new List<T>();
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
base.Dispose();
|
||||
RemoveListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
namespace FlowerPower
|
||||
{
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using IgnoreOPS;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class LoginSystem : BaseSystem
|
||||
{
|
||||
|
||||
private int loginCount = 0;
|
||||
|
||||
private TimerTask timerTask = null;
|
||||
|
||||
public LoginSystem(bool isAutoInit = true)
|
||||
{
|
||||
if (isAutoInit)
|
||||
@@ -37,126 +40,51 @@ namespace FlowerPower
|
||||
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.Login, RequestLogin);
|
||||
}
|
||||
|
||||
private TimerTask timerTask = null;
|
||||
private void RequestLogin(object obj = null)
|
||||
{
|
||||
var requestLoginData = new RequestLoginData
|
||||
|
||||
// if (!GameHelper.IsConnect())
|
||||
// {
|
||||
// LoginFail();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoginSend);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetworkErrorTipsUI_Open);
|
||||
LoginKit.Instance.LoginRequest(SuperApplication.Instance.attribution, NetworkManager.haveSimCard, (isSuccess, loginData) =>
|
||||
{
|
||||
device_id = SystemInfo.deviceUniqueIdentifier,
|
||||
pack_name = NetworkManager.identifier,
|
||||
app_version = Application.version,
|
||||
//is debug test--------
|
||||
channel = SuperApplication.Instance.attribution,
|
||||
sim = NetworkManager.haveSimCard
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoginRecv, isSuccess ? "success" : "fail");
|
||||
|
||||
};
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetworkErrorTipsUI_Close);
|
||||
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginSend",
|
||||
payload = ""
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
Debug.Log("haveSimCard-----login-" + requestLoginData.sim );
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LoginloadingUI_Open);
|
||||
|
||||
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;
|
||||
BIManager.Instance.TrackABConfig(loginData.IsMagic ? 30 : 15);
|
||||
DateTimeManager.Instance.SetServerCurrTimestamp(loginData.LoginTime);
|
||||
|
||||
loginModel.preferences = new Preferences();
|
||||
NetworkKit.CDNUrl = $"{loginData.cdn_url}/";
|
||||
NetworkKit.userId = loginData.uid;
|
||||
NetworkKit.SetCacheToken(loginData.token);
|
||||
DateTimeManager.Instance.SetServerCurrTimestamp(loginData.login_time);
|
||||
RequestHeart();
|
||||
Debug.Log("haveSimCard-----is_magic-" + loginModel.is_magic);
|
||||
|
||||
if (timerTask == null)
|
||||
{
|
||||
// Debug.Log("$ timer task fuzhi---------");
|
||||
timerTask = TimerHelper.UnscaleGeneral.AddLoopTimer(60, (timer) => { RequestHeart(); });
|
||||
}
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.netLoading_close);
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetPlayData);
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginRecv",
|
||||
payload = "success"
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
MaxADKit.SetUserID(loginData.Uid.As<string>());
|
||||
if (loginData.IsMagic) UnityManager.DakaiACT();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (!GameHelper.IsConnect())
|
||||
// {
|
||||
// loginCount = 0;
|
||||
// Action _OnFail = () =>
|
||||
// {
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// };
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, _OnFail);
|
||||
// return;
|
||||
// }
|
||||
var reqData = new RespLoginFunnelData
|
||||
{
|
||||
type = "loginRecv",
|
||||
payload = "fail"
|
||||
};
|
||||
NetworkKit.PostFunnelLogin(reqData);
|
||||
|
||||
float times = loginCount == 0 ? 0.1f : 5f;
|
||||
Debug.Log("dddddd");
|
||||
DOVirtual.DelayedCall(times, () =>
|
||||
{
|
||||
Debug.Log("ssssss");
|
||||
if (loginCount < 5)
|
||||
{
|
||||
loginCount++;
|
||||
RequestLogin();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
loginCount = 0;
|
||||
Action _OnFail = () =>
|
||||
{
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
};
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, _OnFail);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.netLoading_close);
|
||||
}
|
||||
});
|
||||
LoginFail();
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
private void RequestHeart()
|
||||
private static void LoginFail()
|
||||
{
|
||||
NetworkKit.PostWithHeader("user/health");
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
|
||||
// Debug.Log($"barry 心跳: ---------");
|
||||
void OnFail()
|
||||
{
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
}
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, (Action)OnFail);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -165,4 +93,4 @@ namespace FlowerPower
|
||||
RemoveListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
namespace LoveLegend
|
||||
{
|
||||
public class PlayDataSystem : BaseSystem
|
||||
{
|
||||
@@ -16,7 +18,6 @@ namespace FlowerPower
|
||||
{
|
||||
base.Init();
|
||||
|
||||
// do net
|
||||
AddListener();
|
||||
}
|
||||
|
||||
@@ -34,13 +35,15 @@ namespace FlowerPower
|
||||
|
||||
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);
|
||||
NetApi.RequestPlayerData((isSuccess, json) => {
|
||||
// Debug.Log($"barry UserData : {json}");
|
||||
if (isSuccess) {
|
||||
DataMgr.InitPreferences(json);
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
|
||||
}
|
||||
else {
|
||||
Debug.LogError($"OnRequestPlayData isError {json}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,7 +74,7 @@ namespace FlowerPower
|
||||
version = version,
|
||||
data = data
|
||||
};
|
||||
NetworkKit.PostWithHeader("user/updateData", requestData);
|
||||
// NetworkKit.PostWithHeader("user/updateData", requestData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user