Files
TEngine/Assets/GameScripts/Main/Procedure/ProcedureCreateDownloader.cs
ALEXTANG 51254bba57 [+] Procedure
[+] Procedure
2023-04-13 14:37:49 +08:00

57 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using Cysharp.Threading.Tasks;
using TEngine;
using ProcedureOwner = TEngine.IFsm<TEngine.IProcedureManager>;
namespace GameMain
{
public class ProcedureCreateDownloader : ProcedureBase
{
public override bool UseNativeDialog { get; }
protected override void OnEnter(ProcedureOwner procedureOwner)
{
Log.Info("创建补丁下载器");
UILoadMgr.Show(UIDefine.UILoadUpdate,$"创建补丁下载器...");
CreateDownloader(procedureOwner).Forget();
}
private async UniTaskVoid CreateDownloader(ProcedureOwner procedureOwner)
{
await UniTask.Delay(TimeSpan.FromSeconds(0.5f));
var downloader = GameModule.Resource.CreateResourceDownloader();
if (downloader.TotalDownloadCount == 0)
{
Log.Info("Not found any download files !");
ChangeState<ProcedureDownloadOver>(procedureOwner);
}
else
{
//A total of 10 files were found that need to be downloaded
Log.Info($"Found total {downloader.TotalDownloadCount} files that need download ");
// 发现新更新文件后,挂起流程系统
// 注意:开发者需要在下载前检测磁盘空间不足
int totalDownloadCount = downloader.TotalDownloadCount;
long totalDownloadBytes = downloader.TotalDownloadBytes;
float sizeMb = totalDownloadBytes / 1048576f;
sizeMb = UnityEngine.Mathf.Clamp(sizeMb, 0.1f, float.MaxValue);
string totalSizeMb = sizeMb.ToString("f1");
UILoadTip.ShowMessageBox($"Found update patch files, Total count {totalDownloadCount} Total size {totalSizeMb}MB", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_StartUpdate_Notice
, () => { StartDownFile(procedureOwner: procedureOwner); }, UnityEngine.Application.Quit);
}
}
void StartDownFile(ProcedureOwner procedureOwner)
{
ChangeState<ProcedureDownloadFile>(procedureOwner);
}
}
}