【调整】移动部分代码
parent
4f961e1136
commit
fceb8af02a
|
@ -98,7 +98,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &89986407194938043
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -19,6 +19,9 @@ public enum NetRequestStatus
|
|||
|
||||
public class AppNetConfig : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求服务器返回信息类
|
||||
/// </summary>
|
||||
private class ServerResponseInfo
|
||||
{
|
||||
public int code = -1;
|
||||
|
@ -26,6 +29,9 @@ public class AppNetConfig : MonoBehaviour
|
|||
public string data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求获取数据类
|
||||
/// </summary>
|
||||
private class PostData
|
||||
{
|
||||
public string action;
|
||||
|
@ -35,7 +41,9 @@ public class AppNetConfig : MonoBehaviour
|
|||
public string client_type;
|
||||
public string game_data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求上传数据类
|
||||
/// </summary>
|
||||
private class UploadPostData
|
||||
{
|
||||
public string action;
|
||||
|
@ -74,13 +82,13 @@ public class AppNetConfig : MonoBehaviour
|
|||
_serverData = new ServerResponseInfo();
|
||||
_uploadPostData = new UploadPostData();
|
||||
EventManager.Instance.Register<string>(EventManager.EventName.UploadToRemote, StartUpload);
|
||||
EventManager.Instance.Register(EventManager.EventName.NewUserLogin, SaveRemoteData);
|
||||
EventManager.Instance.Register(EventManager.EventName.NewUserLogin, SaveNewUserData);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
EventManager.Instance.Unregister<string>(EventManager.EventName.UploadToRemote, StartUpload);
|
||||
EventManager.Instance.Unregister(EventManager.EventName.NewUserLogin, SaveRemoteData);
|
||||
EventManager.Instance.Unregister(EventManager.EventName.NewUserLogin, SaveNewUserData);
|
||||
}
|
||||
|
||||
private void StartUpload(string jsonData)
|
||||
|
@ -89,7 +97,7 @@ public class AppNetConfig : MonoBehaviour
|
|||
_upload = true;
|
||||
}
|
||||
|
||||
private void SaveRemoteData()
|
||||
private void SaveNewUserData()
|
||||
{
|
||||
DebugUtil.LogWarning("新玩家");
|
||||
var jsonData = JsonConvert.SerializeObject(AppInfoManager.Instance.RemoteAppUserInfo);
|
||||
|
@ -98,7 +106,6 @@ public class AppNetConfig : MonoBehaviour
|
|||
|
||||
private void BindThirdID()
|
||||
{
|
||||
DebugUtil.Log("绑定第三方数据据");
|
||||
var jsonData = JsonConvert.SerializeObject(AppInfoManager.Instance.AppUserInfo);
|
||||
UploadDataToServer(jsonData);
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace Framework.BI
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Framework.BI
|
|||
ByCash,
|
||||
}
|
||||
|
||||
public StorageEvent StorageEvent;
|
||||
private StorageEvent _storageEvent;
|
||||
|
||||
public string ThirdID
|
||||
{
|
||||
|
@ -46,8 +46,8 @@ namespace Framework.BI
|
|||
_biService?.SetUser(DeviceHelper.GetDeviceId());
|
||||
_biService?.SetUserProperty("platform", DeviceHelper.GetPlatformString());
|
||||
|
||||
StorageEvent = StorageManager.Instance.GetStorage<StorageEvent>("StorageEvent");
|
||||
StorageEvent ??= new StorageEvent();
|
||||
_storageEvent = StorageManager.Instance.GetStorage<StorageEvent>("StorageEvent");
|
||||
_storageEvent ??= new StorageEvent();
|
||||
|
||||
_isInit = true;
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ namespace Framework.BI
|
|||
{
|
||||
}
|
||||
|
||||
public bool IsRecorded(cfg.BI.EventFirst eventName)
|
||||
private bool IsRecorded(cfg.BI.EventFirst eventName)
|
||||
{
|
||||
return StorageEvent.EventList.Contains(eventName);
|
||||
return _storageEvent.EventList.Contains(eventName);
|
||||
}
|
||||
|
||||
public bool IsRecorded(string eventName)
|
||||
private bool IsRecorded(string eventName)
|
||||
{
|
||||
return StorageEvent.EventStringList.Contains(eventName);
|
||||
return _storageEvent.EventStringList.Contains(eventName);
|
||||
}
|
||||
|
||||
public void TrackEventOnce(cfg.BI.EventFirst eventName)
|
||||
|
@ -76,7 +76,7 @@ namespace Framework.BI
|
|||
}
|
||||
else
|
||||
{
|
||||
StorageEvent.EventList.Add(eventName);
|
||||
_storageEvent.EventList.Add(eventName);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
_biService?.ReportEvent(eventName.ToString());
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace Framework.BI
|
|||
_biService?.ReportEvent(eventName.ToString(), userParam);
|
||||
_tempEventDictionary.Clear();
|
||||
|
||||
StorageEvent.EventList.Add(eventName);
|
||||
_storageEvent.EventList.Add(eventName);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ namespace Framework.BI
|
|||
}
|
||||
else
|
||||
{
|
||||
StorageEvent.EventStringList.Add(eventName);
|
||||
_storageEvent.EventStringList.Add(eventName);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
_biService?.ReportEvent(eventName);
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ namespace Framework.BI
|
|||
|
||||
_biService?.ReportEvent(eventName.ToString(), levelParam);
|
||||
|
||||
StorageEvent.EventList.Add(eventName);
|
||||
_storageEvent.EventList.Add(eventName);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Framework.Event
|
|||
|
||||
private void ReCycleTempExecuteList(List<Delegate> list)
|
||||
{
|
||||
if (_tempExecutePool.Count < MAX_EVENT_STACK)
|
||||
if (_tempExecutePool.Count < MaxEventStack)
|
||||
{
|
||||
list.Clear();
|
||||
_tempExecutePool.Push(list);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PhxhSDK;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Framework.Event
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace Framework.Event
|
|||
remove => _afterSendCallBack -= value;
|
||||
}
|
||||
|
||||
public const int MAX_EVENT_STACK = 3;
|
||||
private const int MaxEventStack = 3;
|
||||
|
||||
public void Register<T>(EventName eventName, Action<T> action)
|
||||
{
|
||||
|
@ -177,9 +177,9 @@ namespace Framework.Event
|
|||
|
||||
private bool EventStackReachMax(int current)
|
||||
{
|
||||
if (current > MAX_EVENT_STACK)
|
||||
if (current > MaxEventStack)
|
||||
{
|
||||
DebugUtil.EditorAssert(_eventStack <= MAX_EVENT_STACK, $"EventSystem.Send<T> : {MAX_EVENT_STACK}");
|
||||
DebugUtil.EditorAssert(_eventStack <= MaxEventStack, $"EventSystem.Send<T> : {MaxEventStack}");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Framework.Event
|
|||
{
|
||||
LevelGameWin,
|
||||
LevelGameLose,
|
||||
LoginSuccess,
|
||||
//LoginSuccess,
|
||||
LoginFail,
|
||||
NewBieGuideNext,
|
||||
NewBieGuideFinish,
|
||||
|
|
|
@ -4,6 +4,9 @@ using Framework.Event;
|
|||
using Framework.Manager;
|
||||
using LC.Newtonsoft.Json;
|
||||
|
||||
/// <summary>
|
||||
/// 用户需要上传至服务器的的游戏数据类
|
||||
/// </summary>
|
||||
public class AppUserInfo
|
||||
{
|
||||
public UserInfo UserInfo;
|
||||
|
@ -38,27 +41,22 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
public bool GetRemoteInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要同步数据
|
||||
/// 是否需要展示同步数据UI
|
||||
/// </summary>
|
||||
public bool UpdateConfirm;
|
||||
|
||||
/// <summary>
|
||||
/// 存取数据的方式
|
||||
/// 存取数据的方式 本地/登录
|
||||
/// </summary>
|
||||
public NetConfigID CurLoginState = NetConfigID.None;
|
||||
|
||||
/// <summary>
|
||||
/// 数据是否同步至最新
|
||||
/// </summary>
|
||||
private bool _isUpdateToLatest;
|
||||
|
||||
/// <summary>
|
||||
/// 向服务器请求的间隔时间
|
||||
/// </summary>
|
||||
private float RemoteInterval = 10.0f;
|
||||
private const float RemoteInterval = 10.0f;
|
||||
|
||||
//临时变量
|
||||
private float RemoteTickTime { get; set; }
|
||||
|
||||
private bool _init;
|
||||
private string _tempIdToken = "";
|
||||
private LoginStatusID _tempLoginStatus;
|
||||
|
@ -68,7 +66,7 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
_appUserInfo = StorageManager.Instance.GetStorage<AppUserInfo>("UserInfo");
|
||||
_appUserInfo ??= new AppUserInfo();
|
||||
SyncInfo(RemoteAppUserInfo, _appUserInfo);
|
||||
DebugUtil.Log("本地读到的信息: UserID: {0}, ThirdID: {1}",
|
||||
DebugUtil.Log("本地读到的玩家ID信息: UserID: {0}, ThirdID: {1}",
|
||||
_appUserInfo.UserInfo.UserID, _appUserInfo.UserInfo.ThirdId);
|
||||
}
|
||||
|
||||
|
@ -76,11 +74,11 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
{
|
||||
if (_init)
|
||||
return;
|
||||
//检测本地是否有缓存
|
||||
|
||||
//检测本地是否有第三方缓存 有缓存则向服务器请求
|
||||
CurLoginState = !string.IsNullOrEmpty(_appUserInfo.UserInfo.ThirdId)
|
||||
? NetConfigID.ThirdID
|
||||
: NetConfigID.DeviceID;
|
||||
|
||||
LoginManager.Instance.IsLogin = !string.IsNullOrEmpty(_appUserInfo.UserInfo.ThirdId);
|
||||
AppNetConfig.State = NetRequestStatus.Start;
|
||||
_init = true;
|
||||
|
@ -88,6 +86,9 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
DebugUtil.Log("当前的向服务器请求的账号是: {0},登录状态: {1}", CurLoginState, LoginManager.Instance.IsLogin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前存取数据的ID
|
||||
/// </summary>
|
||||
public string GetUniqueID()
|
||||
{
|
||||
return CurLoginState == NetConfigID.ThirdID
|
||||
|
@ -100,6 +101,36 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
return ((int)CurLoginState).ToString();
|
||||
}
|
||||
|
||||
|
||||
#region 玩家数据设置
|
||||
|
||||
public void SetLocalVersion(ulong version)
|
||||
{
|
||||
_appUserInfo.UserInfo.Version = version;
|
||||
}
|
||||
|
||||
public void SetRemoteVersion(ulong version)
|
||||
{
|
||||
RemoteAppUserInfo.UserInfo.Version = version;
|
||||
}
|
||||
|
||||
public void SetRemoteData(int newCoins = 0, string newPassLevel = null)
|
||||
{
|
||||
if (newCoins != 0)
|
||||
{
|
||||
RemoteAppUserInfo.Coins = newCoins;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(newPassLevel))
|
||||
{
|
||||
RemoteAppUserInfo.PassLevel = newPassLevel;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 登录情况处理
|
||||
|
||||
/// <summary>
|
||||
/// 第三方成功登录后 更新本地用户信息
|
||||
/// </summary>
|
||||
|
@ -114,36 +145,8 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
_appUserInfo.UserInfo.UserID, _appUserInfo.UserInfo.ThirdId, _appUserInfo.LoginStatusID);
|
||||
}
|
||||
|
||||
public void SetLocalVersion(ulong version)
|
||||
{
|
||||
_appUserInfo.UserInfo.Version = version;
|
||||
}
|
||||
|
||||
public void SetRemoteVersion(ulong version)
|
||||
{
|
||||
RemoteAppUserInfo.UserInfo.Version = version;
|
||||
}
|
||||
|
||||
public void SetRemoteData(int newCoins = 0, string newPassLevel = null)
|
||||
{
|
||||
if (newCoins != 0 && _isUpdateToLatest)
|
||||
{
|
||||
RemoteAppUserInfo.Coins = newCoins;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(newPassLevel) && _isUpdateToLatest)
|
||||
{
|
||||
RemoteAppUserInfo.PassLevel = newPassLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckLogin()
|
||||
{
|
||||
return AppUserInfo.LoginStatusID != LoginStatusID.None && !string.IsNullOrEmpty(AppUserInfo.UserInfo.ThirdId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备id登录成功 有第三方id数据和无的处理方式
|
||||
/// 设备id登录成功 第三方id数据有和无的处理方式
|
||||
/// </summary>
|
||||
public void DeviceIdGetSuccess(string gameData)
|
||||
{
|
||||
|
@ -159,7 +162,7 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
CurLoginState = NetConfigID.ThirdID;
|
||||
AppNetConfig.State = NetRequestStatus.Start;
|
||||
}
|
||||
//无 直接比对
|
||||
//无 直接比对数据
|
||||
else
|
||||
{
|
||||
DebugUtil.Log("设备id登录成功,无第三方id数据");
|
||||
|
@ -208,7 +211,6 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
}
|
||||
else
|
||||
{
|
||||
_isUpdateToLatest = true;
|
||||
SyncInfo(_appUserInfo, RemoteAppUserInfo);
|
||||
DebugUtil.LogWarning("仅版本不同, 更新版本, 远端: {0}, 本地: {1}", remoteVersion, localVersion);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
|
@ -226,7 +228,6 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
}
|
||||
else
|
||||
{
|
||||
_isUpdateToLatest = true;
|
||||
SyncInfo(RemoteAppUserInfo, _appUserInfo);
|
||||
DebugUtil.LogWarning("仅版本不同, 更新版本, 远端: {0}, 本地: {1}", remoteVersion, localVersion);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
|
@ -235,13 +236,22 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
}
|
||||
else
|
||||
{
|
||||
_isUpdateToLatest = true;
|
||||
DebugUtil.Log("远端和本地数据相同,不需要更新");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 界面选择数据进行同步
|
||||
/// 检查是否已登录
|
||||
/// </summary>
|
||||
public bool CheckIfLogin()
|
||||
{
|
||||
return AppUserInfo.LoginStatusID != LoginStatusID.None && !string.IsNullOrEmpty(AppUserInfo.UserInfo.ThirdId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面玩家选择同步数据方法
|
||||
/// </summary>
|
||||
public void SyncGameData(bool toRemote = true)
|
||||
{
|
||||
|
@ -256,16 +266,21 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
|
|||
DebugUtil.LogWarning("更新至本地数据");
|
||||
}
|
||||
|
||||
_isUpdateToLatest = true;
|
||||
UpdateConfirm = false;
|
||||
EventManager.Instance.Send(EventManager.EventName.RefreshGameData);
|
||||
StorageManager.Instance.SyncForce = true;
|
||||
StorageManager.Instance.SyncRemoteForce = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复制用户数据
|
||||
/// </summary>
|
||||
/// <param name="userInfo">旧数据</param>
|
||||
/// <param name="newUserInfo">新数据</param>
|
||||
/// <param name="isEmpty">是否更为空数据</param>
|
||||
private void SyncInfo(AppUserInfo userInfo, AppUserInfo newUserInfo, bool isEmpty = false)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(newUserInfo);
|
||||
var json = JsonConvert.SerializeObject(newUserInfo);
|
||||
AppUserInfo tempInfo = JsonConvert.DeserializeObject<AppUserInfo>(json);
|
||||
|
||||
userInfo.UserInfo.ThirdId = tempInfo.UserInfo.ThirdId;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Framework.Manager
|
|||
{
|
||||
return key;
|
||||
}
|
||||
return getValue.Value;
|
||||
return getValue.ValueEn;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.IO;
|
||||
using Framework.Event;
|
||||
using LC.Newtonsoft.Json;
|
||||
using LC.Newtonsoft.Json.Linq;
|
||||
|
|
|
@ -19,15 +19,15 @@ namespace Framework
|
|||
{
|
||||
}
|
||||
|
||||
public static JSONNode LoadByteBuf(string file)
|
||||
private static JSONNode LoadByteBuf(string file)
|
||||
{
|
||||
var filePath = _CombiePath(file);
|
||||
var filePath = _CombinePath(file);
|
||||
var loadAsset = AssetManager.Instance.LoadAsset<TextAsset>(filePath);
|
||||
var jsonText = loadAsset.text;
|
||||
return JSON.Parse(jsonText);
|
||||
}
|
||||
|
||||
private static string _CombiePath(string fileName)
|
||||
private static string _CombinePath(string fileName)
|
||||
{
|
||||
return string.Format(Constants.Constants.TableDataConfigPath, fileName);
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ namespace Framework
|
|||
|
||||
private void _UnlockJson(string fileName)
|
||||
{
|
||||
var fullPath = _CombiePath(fileName);
|
||||
var fullPath = _CombinePath(fileName);
|
||||
AssetManager.Instance.Unload(fullPath);
|
||||
}
|
||||
|
||||
private void _PostPreload(string fileName)
|
||||
{
|
||||
var fullPath = _CombiePath(fileName);
|
||||
var fullPath = _CombinePath(fileName);
|
||||
AssetManager.Instance.PostPreload(fullPath);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Framework.Event;
|
||||
using Framework.Manager;
|
||||
using Framework.Event;
|
||||
using Framework.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
[RequireComponent(typeof(TMP_Text))]
|
||||
public class LocalizeText : MonoBehaviour
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace Framework.UI
|
|||
{
|
||||
case (LanguageType.Default):
|
||||
{
|
||||
value = data.Value;
|
||||
value = data.ValueEn;
|
||||
break;
|
||||
}
|
||||
case (LanguageType.CN):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
|
@ -62,7 +62,7 @@ namespace Gameplay.LoadingExecutor
|
|||
if (AppInfoManager.Instance.UpdateConfirm)
|
||||
await UIManager.Instance.OpenWindow(UIConstants.UISyncTip);
|
||||
|
||||
if (!AppInfoManager.Instance.CheckLogin() && !LoginManager.Instance.ShowLogin)
|
||||
if (!AppInfoManager.Instance.CheckIfLogin() && !LoginManager.Instance.ShowLogin)
|
||||
await UIManager.Instance.OpenWindow(UIConstants.UILogin);
|
||||
|
||||
if (!PlayerPrefs.HasKey(LevelConstants.FirstLaunch))
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LoginStatusApple : LoginStatus
|
|||
//从服务器获取数据
|
||||
GetDataFromSever();
|
||||
|
||||
EventManager.Instance.Send(EventManager.EventName.LoginSuccess);
|
||||
//EventManager.Instance.Send(EventManager.EventName.LoginSuccess);
|
||||
DebugUtil.LogWarning("Apple登录成功:userID: {0}", userID);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Gameplay.Login
|
|||
//从服务器获取数据
|
||||
GetDataFromSever();
|
||||
|
||||
EventManager.Instance.Send(EventManager.EventName.LoginSuccess);
|
||||
//EventManager.Instance.Send(EventManager.EventName.LoginSuccess);
|
||||
DebugUtil.LogWarning("FaceBook登录成功:userID: {0}", userID);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue