AlicizaX/Client/Assets/Scripts/Startup/Framework/Procedure/ProcedureGetGlobalInfoState.cs
2025-04-28 19:45:45 +08:00

56 lines
1.5 KiB
C#

using System;
using Cysharp.Threading.Tasks;
using AlicizaX;
using UnityEngine;
using YooAsset;
namespace Unity.Startup.Procedure
{
/// <summary>
/// 获取全局信息
/// </summary>
public sealed class ProcedureGetGlobalInfoState : StateBase<UpdateProcedureState>
{
protected override void OnEnter()
{
base.OnEnter();
if (GameApp.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
SwitchState(UpdateProcedureState.ProcedureGetAppVersionInfoState);
return;
}
if (GameApp.Resource.PlayMode == EPlayMode.OfflinePlayMode)
{
SwitchState(UpdateProcedureState.ProcedurePatchInit);
return;
}
//检查设备是否能够访问互联网
if (Application.internetReachability == NetworkReachability.NotReachable)
{
Log.Warning("The device is not connected to the network");
return;
}
GetGlobalInfo();
}
private async void GetGlobalInfo()
{
try
{
await HttpHelper.GetRemoteVersion();
SwitchState(UpdateProcedureState.ProcedureGetAppVersionInfoState);
}
catch (Exception e)
{
Log.Error(e.Message);
await UniTask.Delay(3000);
GetGlobalInfo();
}
}
}
}