【重构】修改部分代码结构

Android_release
zhangaotian 2024-08-07 15:22:09 +08:00
parent b6cc31125d
commit f5ca0a09a7
39 changed files with 50 additions and 126 deletions

View File

@ -1,22 +0,0 @@
using System.Collections.Generic;
namespace Framework.BI
{
public class StorageEvent
{
public List<cfg.BI.EventFirst> EventList { get; set; }
public List<string> EventStringList { get; set; }
public StorageEvent()
{
EventList = new List<cfg.BI.EventFirst>();
EventStringList = new List<string>();
}
public StorageEvent(List<cfg.BI.EventFirst> eventList, List<string> eventStringList)
{
EventList = eventList;
EventStringList = eventStringList;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 26fe57136a139b143adb61d2c369f697
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9c695725f8dddec4a9b762ca20abcd38
guid: 4f9d31ed566734befa902f69b0264d6b
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -17,7 +17,7 @@ public enum NetRequestStatus
Success,
}
public class AppNetConfig : MonoBehaviour
public class Forest_AppNetConfig : MonoBehaviour
{
/// <summary>
/// 请求服务器返回信息类
@ -41,6 +41,7 @@ public class AppNetConfig : MonoBehaviour
public string client_type;
public string game_data;
}
/// <summary>
/// 请求上传数据类
/// </summary>
@ -99,7 +100,6 @@ public class AppNetConfig : MonoBehaviour
private void SaveNewUserData()
{
DebugUtil.LogWarning("新玩家");
var jsonData = JsonConvert.SerializeObject(AppInfoManager.Instance.RemoteAppUserInfo);
UploadDataToServer(jsonData);
}
@ -131,7 +131,7 @@ public class AppNetConfig : MonoBehaviour
{
var uniqueID = AppInfoManager.Instance.GetUniqueID();
var uniqueType = AppInfoManager.Instance.GetUniqueType();
DebugUtil.Log("使用{0}获取数据, ID:{1}", AppInfoManager.Instance.CurLoginState, uniqueID);
DebugUtil.Log("Use {0} Get Data, ID:{1}", AppInfoManager.Instance.CurLoginState, uniqueID);
HTTPRequest request = new HTTPRequest(new Uri(URL), HTTPMethods.Post, OnGetFinished);
request.SetHeader("Content-Type", "application/json");
_createSign = GenerateHash("get_data", uniqueID);
@ -147,7 +147,7 @@ public class AppNetConfig : MonoBehaviour
var jsonData = JsonConvert.SerializeObject(_postData);
if (string.IsNullOrEmpty(jsonData))
DebugUtil.LogError("Json转化后postDataJson为空");
DebugUtil.LogError("GetDataFromServer : Error Json ConvertpostDataJson is null");
var bytes = Encoding.UTF8.GetBytes(jsonData);
request.RawData = bytes;
@ -178,14 +178,16 @@ public class AppNetConfig : MonoBehaviour
//查不到第三方信息 但是本地有 绑定
if (loginIDState == AppInfoManager.NetConfigID.ThirdID && _deviceLoginSuccess)
{
DebugUtil.Log("查不到第三方信息 但是本地有, 保存数据, 服务器返回消息:{0}", jsonData);
DebugUtil.Log(
"Can't find ThirdID, but local have! Bind ThirdID, Server return Message : {0}",
jsonData);
BindThirdID();
_thirdLoginSuccess = true;
}
//其余情况以设备id注册新玩家
else
{
DebugUtil.Log("无设备ID和第三方ID, 新玩家, 先保存数据");
DebugUtil.Log("New User (No DeviceID and ThirdID)");
_isNewUser = true;
EventManager.Instance.Send(EventManager.EventName.NewUserLogin);
}
@ -198,29 +200,31 @@ public class AppNetConfig : MonoBehaviour
_serverData.data = data["game_data"]?.ToString();
if (!string.IsNullOrEmpty(_serverData.data))
{
//第一次使用第三方id获取成功设备id无登录
if (loginIDState == AppInfoManager.NetConfigID.ThirdID && !_deviceLoginSuccess)
{
_thirdLoginSuccess = true;
AppInfoManager.Instance.ThirdIdGetSuccess(_serverData.data);
DebugUtil.Log("第一次使用第三方id获取成功设备id无登录");
DebugUtil.Log("First ThirdID GetData Success, No DeviceID");
}
//后续登录 和 设备id获取得到第三方id的情况
else if (loginIDState == AppInfoManager.NetConfigID.ThirdID && _deviceLoginSuccess)
{
_thirdLoginSuccess = true;
AppInfoManager.Instance.ThirdIdGetSuccessWithDevice(_serverData.data);
DebugUtil.Log("使用第三方id获取成功");
DebugUtil.Log("ThirdID GetData Success");
}
//本地有设备id缓存 并且没登录过第三方
else if (loginIDState == AppInfoManager.NetConfigID.DeviceID && !_thirdLoginSuccess)
{
_deviceLoginSuccess = true;
AppInfoManager.Instance.DeviceIdGetSuccess(_serverData.data);
DebugUtil.Log("使用设备id获取成功进行有无第三方id判断");
DebugUtil.Log("DeviceID GetData Success, Judge ThirdID");
}
//设备id获取成功但是第三方也成功登录的情况
else
{
DebugUtil.Log("设备id获取成功但是第三方也成功登录的情况");
DebugUtil.Log("DeviceID and ThirdID GetData Success");
}
}
}
@ -258,7 +262,7 @@ public class AppNetConfig : MonoBehaviour
{
var clientID = AppInfoManager.Instance.AppUserInfo.UserInfo.UserID;
var thirdID = AppInfoManager.Instance.AppUserInfo.UserInfo.ThirdId;
DebugUtil.Log("上传的玩家数据, clientID:{0}, thirdID: {1}gameData:{2}", clientID, thirdID, data);
DebugUtil.Log("Upload Data, clientID:{0}, thirdID: {1}gameData:{2}", clientID, thirdID, data);
var request = new HTTPRequest(new Uri(URL), HTTPMethods.Post, NewOnUploadFinished);
request.SetHeader("Content-Type", "application/json");
@ -274,7 +278,7 @@ public class AppNetConfig : MonoBehaviour
};
string jsonData = JsonConvert.SerializeObject(_uploadPostData);
if (string.IsNullOrEmpty(jsonData))
DebugUtil.LogError("Json转化后, uploadPostDat为空");
DebugUtil.LogError("UploadDataToServer : Error Json ConvertuploadPostDat is null");
DebugUtil.Log("UploadData.Post信息{0}", jsonData);
var bytes = Encoding.UTF8.GetBytes(jsonData);
request.RawData = bytes;
@ -295,13 +299,13 @@ public class AppNetConfig : MonoBehaviour
case HTTPRequestStates.Finished:
{
var jsonData = response.DataAsText;
DebugUtil.Log("Upload从服务器获取到的数据{0}", jsonData);
DebugUtil.Log("Upload Sever Return jsonData{0}", jsonData);
JObject jObj = JObject.Parse(jsonData);
_serverData.code = (int)jObj["code"];
_serverData.message = jObj["message"]?.ToString();
if (_serverData.code == 0)
{
DebugUtil.Log("服务器保存数据成功 !!!!");
DebugUtil.Log("Server Save Successfully !!!!");
if (_isNewUser)
GetDataFromServer();
}

View File

@ -1,17 +0,0 @@
using Cysharp.Threading.Tasks;
using Framework.Manager;
using Gameplay.LoadingExecutor;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;
namespace Framework.GameBuild
{
public class GameBuildLoadingExecutor : LoadingExecutorWithUILoadingController
{
protected override async UniTask _DoLoading()
{
await Addressables.LoadSceneAsync(Constants.Constants.SceneBuildPath, LoadSceneMode.Single).ToUniTask();
_destProgress = 100f;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c2689db812d4c4839b9d01b980ec14ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,22 +0,0 @@
using Framework.State;
using Gameplay.LoadingExecutor;
namespace Framework.GameBuild
{
public class GameBuildStateStart : IState
{
public void OnEnter()
{
LoadingExecutorManager.Instance.ExecuteLoading(
new GameBuildLoadingExecutor());
}
public void OnUpdate(float deltaTime)
{
}
public void OnExit()
{
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7aa43c76d684c4426855c04cf4b98f0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -71,7 +71,7 @@ public class LoginStatusApple : LoginStatus
private void GetDataFromSever()
{
AppInfoManager.Instance.CurLoginState = AppInfoManager.NetConfigID.ThirdID;
AppNetConfig.State = NetRequestStatus.Start;
Forest_AppNetConfig.State = NetRequestStatus.Start;
}
private void OnLoginFail(int code, string msg)

View File

@ -63,7 +63,7 @@ namespace Gameplay.Login
private void GetDataFromSever()
{
AppInfoManager.Instance.CurLoginState = AppInfoManager.NetConfigID.ThirdID;
AppNetConfig.State = NetRequestStatus.Start;
Forest_AppNetConfig.State = NetRequestStatus.Start;
}
private void OnLoginFail(int code, string msg)

View File

@ -80,7 +80,7 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
? NetConfigID.ThirdID
: NetConfigID.DeviceID;
LoginManager.Instance.IsLogin = !string.IsNullOrEmpty(_appUserInfo.UserInfo.ThirdId);
AppNetConfig.State = NetRequestStatus.Start;
Forest_AppNetConfig.State = NetRequestStatus.Start;
_init = true;
DebugUtil.Log("当前的向服务器请求的账号是: {0},登录状态: {1}", CurLoginState, LoginManager.Instance.IsLogin);
@ -160,7 +160,7 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
DebugUtil.Log("设备id登录成功有第三方id数据:{0},进行获取", _tempIdToken);
_appUserInfo.UserInfo.ThirdId = _tempIdToken;
CurLoginState = NetConfigID.ThirdID;
AppNetConfig.State = NetRequestStatus.Start;
Forest_AppNetConfig.State = NetRequestStatus.Start;
}
//无 直接比对数据
else
@ -319,7 +319,7 @@ public class AppInfoManager : Singlenton<AppInfoManager>, IInitable, IUpdatable
if (_init && !GetRemoteInfo && RemoteTickTime > RemoteInterval)
{
RemoteTickTime = 0.0f;
AppNetConfig.State = NetRequestStatus.Start;
Forest_AppNetConfig.State = NetRequestStatus.Start;
DebugUtil.Log("... 尝试再次从服务器读取玩家数据 ...");
}
}

View File

@ -6,6 +6,24 @@ using System;
namespace Framework.BI
{
public class StorageEvent
{
public List<cfg.BI.EventFirst> EventList { get; set; }
public List<string> EventStringList { get; set; }
public StorageEvent()
{
EventList = new List<cfg.BI.EventFirst>();
EventStringList = new List<string>();
}
public StorageEvent(List<cfg.BI.EventFirst> eventList, List<string> eventStringList)
{
EventList = eventList;
EventStringList = eventStringList;
}
}
public class BIManager : Singlenton<BIManager>, IInitable
{
public enum Reason

View File

@ -5,7 +5,7 @@ using PhxhSDK;
namespace Gameplay.Game
{
public class Main : MonoBehaviour
public class Forest_Main : MonoBehaviour
{
public static PhxhSDK.Game Game
{
@ -26,10 +26,9 @@ namespace Gameplay.Game
AdSDKManager.Instance.ConfigureBeforeInit(unityAdsGameID);
AdSDKManager.Instance.Init();
IAPManager.Instance.Init();
_InitReport();
DontDestroyOnLoad(gameObject);
_game = new MyGame();
_game = new Forest_MyGame();
if (_game == null)
{
DebugUtil.LogError("Framework.Main: no game instance created");
@ -38,10 +37,6 @@ namespace Gameplay.Game
_game.Init();
}
private void _InitReport()
{
}
private void Start()
{
BIManager.Instance.TrackEventOnce(cfg.BI.EventFirst.fte_open);

View File

@ -5,12 +5,11 @@ using Gameplay.Game;
using Gameplay.Login;
using Gameplay.Manager;
using Framework.Manager;
using Framework.Constants;
using Gameplay.LoadingExecutor;
namespace Gameplay
{
public class MyGame : PhxhSDK.Game
public class Forest_MyGame : PhxhSDK.Game
{
protected override void _RegisterSubSystems()
{

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9aa1071553b4ea34abc5619c1f640127
guid: 86a901e94234d4099a196d78c682d9db
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -1,4 +1,6 @@
using cfg.BI;
//// 旧的主界面
/*using cfg.BI;
using UnityEngine;
using Framework.BI;
using Framework.UI;
@ -134,4 +136,4 @@ public class UIMainPanelController : UIWindow
UnregisterEvent();
UIManager.Instance.CloseWindow(UIConstants.UIMainPanelBg);
}
}
}*/