using System;
using Cysharp.Threading.Tasks;
using AlicizaX;
using UnityEngine;
using YooAsset;
namespace Unity.Startup.Procedure
{
///
/// 获取全局信息
///
public sealed class ProcedureGetGlobalInfoState : StateBase
{
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();
}
}
}
}