Update samples
This commit is contained in:
+4
-1
@@ -2,13 +2,16 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 清理未使用的缓存文件
|
||||
/// </summary>
|
||||
internal class FsmClearCache : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmClearCache);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("清理未使用的缓存文件!");
|
||||
Debug.Log("开始清理未使用的缓存文件!");
|
||||
var package = YooAsset.YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
var operation = package.ClearPackageUnusedCacheFilesAsync();
|
||||
operation.Completed += Operation_Completed;
|
||||
|
||||
+5
-2
@@ -3,14 +3,18 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件下载器
|
||||
/// </summary>
|
||||
public class FsmCreateDownloader : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmCreateDownloader);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("创建补丁下载器!");
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.CreateDownloader);
|
||||
BootScene.Instance.StartCoroutine(CreateDownloader());
|
||||
GameBoot.Instance.StartCoroutine(CreateDownloader());
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
@@ -23,7 +27,6 @@ public class FsmCreateDownloader : IFsmNode
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
Debug.Log("创建补丁下载器.");
|
||||
int downloadingMaxNum = 10;
|
||||
int failedTryAgain = 3;
|
||||
PatchManager.Downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
|
||||
|
||||
+6
-1
@@ -1,14 +1,19 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 下载更新文件
|
||||
/// </summary>
|
||||
public class FsmDownloadFiles : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmDownloadFiles);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("开始下载补丁文件!");
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.DownloadWebFiles);
|
||||
BootScene.Instance.StartCoroutine(BeginDownload());
|
||||
GameBoot.Instance.StartCoroutine(BeginDownload());
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
|
||||
+4
-2
@@ -2,15 +2,17 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 更新完毕
|
||||
/// </summary>
|
||||
internal class FsmPatchDone : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmPatchDone);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.PatchDone);
|
||||
Debug.Log("补丁流程更新完毕!");
|
||||
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.PatchDone);
|
||||
FsmManager.Transition(nameof(FsmClearCache));
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
|
||||
+4
-8
@@ -2,6 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化工作
|
||||
/// </summary>
|
||||
internal class FsmPatchInit : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmPatchInit);
|
||||
@@ -12,7 +15,7 @@ internal class FsmPatchInit : IFsmNode
|
||||
var go = Resources.Load<GameObject>("PatchWindow");
|
||||
GameObject.Instantiate(go);
|
||||
|
||||
BootScene.Instance.StartCoroutine(Begin());
|
||||
FsmManager.Transition(nameof(FsmUpdateVersion));
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
@@ -20,11 +23,4 @@ internal class FsmPatchInit : IFsmNode
|
||||
void IFsmNode.OnExit()
|
||||
{
|
||||
}
|
||||
|
||||
private IEnumerator Begin()
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
FsmManager.Transition(nameof(FsmUpdateVersion));
|
||||
}
|
||||
}
|
||||
+3
@@ -2,6 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 开始游戏
|
||||
/// </summary>
|
||||
internal class FsmStartGame : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmStartGame);
|
||||
|
||||
+5
-2
@@ -3,14 +3,18 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 更新补丁清单
|
||||
/// </summary>
|
||||
public class FsmUpdateManifest : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmUpdateManifest);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("开始更新资源版本清单!");
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.UpdateManifest);
|
||||
BootScene.Instance.StartCoroutine(UpdateManifest());
|
||||
GameBoot.Instance.StartCoroutine(UpdateManifest());
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
@@ -23,7 +27,6 @@ public class FsmUpdateManifest : IFsmNode
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
// 更新补丁清单
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
var operation = package.UpdatePackageManifestAsync(PatchManager.PackageVersion, 30);
|
||||
yield return operation;
|
||||
|
||||
+5
-2
@@ -3,14 +3,18 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 更新资源版本号
|
||||
/// </summary>
|
||||
internal class FsmUpdateVersion : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmUpdateVersion);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("开始获取资源版本号!");
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.UpdateStaticVersion);
|
||||
BootScene.Instance.StartCoroutine(GetStaticVersion());
|
||||
GameBoot.Instance.StartCoroutine(GetStaticVersion());
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
@@ -23,7 +27,6 @@ internal class FsmUpdateVersion : IFsmNode
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
// 更新资源版本号
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
var operation = package.UpdatePackageVersionAsync(30);
|
||||
yield return operation;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public static class PatchManager
|
||||
{
|
||||
_isRun = true;
|
||||
|
||||
Debug.Log("开始补丁更新...");
|
||||
Debug.Log("开启补丁更新流程...");
|
||||
|
||||
// 注意:按照先后顺序添加流程节点
|
||||
FsmManager.AddNode(new FsmPatchInit());
|
||||
|
||||
Reference in New Issue
Block a user