[+] Procedure

[+] Procedure
This commit is contained in:
ALEXTANG
2023-04-13 14:37:49 +08:00
parent a6958f39e7
commit 51254bba57
29 changed files with 1077 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
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);
}
}
}