AlicizaX/Client/Assets/Scripts/Startup/Procedure/PatchUpdater/ProcedureEntryState.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2025-01-23 19:06:48 +08:00
using System;
using Cysharp.Threading.Tasks;
2025-04-28 19:45:45 +08:00
using AlicizaX;
2025-10-14 15:42:34 +08:00
using AlicizaX.Localization;
2025-01-23 19:06:48 +08:00
using UnityEngine;
using YooAsset;
namespace Unity.Startup.Procedure
{
/// <summary>
2025-10-14 15:42:34 +08:00
/// 启动游戏
2025-01-23 19:06:48 +08:00
/// </summary>
2025-10-14 15:42:34 +08:00
public class ProcedureEntryState : StateBase<UpdateProcedureState>
2025-01-23 19:06:48 +08:00
{
2025-04-28 19:45:45 +08:00
protected override void OnEnter()
2025-01-23 19:06:48 +08:00
{
2025-10-14 15:42:34 +08:00
LauncherUIHandler.Start();
if (GameApp.Resource.PlayMode == EPlayMode.OfflinePlayMode || GameApp.Resource.PlayMode == EPlayMode.EditorSimulateMode)
2025-01-23 19:06:48 +08:00
{
2025-10-14 15:42:34 +08:00
SwitchState(UpdateProcedureState.ProcedureInitPackageState);
2025-01-23 19:06:48 +08:00
return;
}
//检查设备是否能够访问互联网
if (Application.internetReachability == NetworkReachability.NotReachable)
{
Log.Warning("The device is not connected to the network");
return;
}
2025-10-14 15:42:34 +08:00
GetRemoteVersionInfo();
2025-01-23 19:06:48 +08:00
}
2025-10-14 15:42:34 +08:00
private async void GetRemoteVersionInfo()
2025-01-23 19:06:48 +08:00
{
try
{
2025-04-28 19:45:45 +08:00
await HttpHelper.GetRemoteVersion();
SwitchState(UpdateProcedureState.ProcedureGetAppVersionInfoState);
2025-01-23 19:06:48 +08:00
}
catch (Exception e)
{
Log.Error(e.Message);
await UniTask.Delay(3000);
2025-10-14 15:42:34 +08:00
GetRemoteVersionInfo();
2025-01-23 19:06:48 +08:00
}
}
}
2025-01-26 20:55:39 +08:00
}