|
@@ -13,23 +13,13 @@ namespace GFGGame
|
|
public class VersionController : SingletonMonoBase<VersionController>
|
|
public class VersionController : SingletonMonoBase<VersionController>
|
|
{
|
|
{
|
|
//private UpdateVersions updateVersions;
|
|
//private UpdateVersions updateVersions;
|
|
- public const string PackageName_GameLogic = "GameLogic";
|
|
|
|
- public const string PackageName_GameArt = "ArtRes";
|
|
|
|
-
|
|
|
|
- private string[] packageNameArr = new string[] {PackageName_GameLogic, PackageName_GameArt };
|
|
|
|
- private Dictionary<string, bool> packageStateDic = new Dictionary<string, bool>();
|
|
|
|
|
|
+ public const string DefaultPackage = "GameLogic";
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 包裹的版本信息
|
|
/// 包裹的版本信息
|
|
/// </summary>
|
|
/// </summary>
|
|
public string PackageVersion { set; get; }
|
|
public string PackageVersion { set; get; }
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 下载器
|
|
|
|
- /// </summary>
|
|
|
|
- public ResourceDownloaderOperation Downloader { set; get; }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
public void Init()
|
|
public void Init()
|
|
{
|
|
{
|
|
@@ -46,23 +36,17 @@ namespace GFGGame
|
|
//var operation = Versions.InitializeAsync(LauncherConfig.CDN_ROOT);
|
|
//var operation = Versions.InitializeAsync(LauncherConfig.CDN_ROOT);
|
|
//yield return operation;
|
|
//yield return operation;
|
|
|
|
|
|
- yield return InitGameLogicPackage();
|
|
|
|
-
|
|
|
|
- yield return InitGameArtPackage();
|
|
|
|
-
|
|
|
|
- yield return GetStaticVersion(PackageName_GameLogic);
|
|
|
|
- yield return UpdateManifest(PackageName_GameLogic);
|
|
|
|
|
|
+ yield return InitDefaultPackage();
|
|
|
|
+ yield return GetStaticVersion(DefaultPackage);
|
|
|
|
+ yield return UpdateManifest(DefaultPackage);
|
|
|
|
|
|
- yield return GetStaticVersion(PackageName_GameArt);
|
|
|
|
- yield return UpdateManifest(PackageName_GameArt);
|
|
|
|
-
|
|
|
|
- OnPackageDownloadCompleted(null);
|
|
|
|
|
|
+ CreateDownloader(DefaultPackage);
|
|
}
|
|
}
|
|
|
|
|
|
- private IEnumerator InitGameLogicPackage()
|
|
|
|
|
|
+ private IEnumerator InitDefaultPackage()
|
|
{
|
|
{
|
|
// 创建默认的资源包
|
|
// 创建默认的资源包
|
|
- string packageName = PackageName_GameLogic;
|
|
|
|
|
|
+ string packageName = DefaultPackage;
|
|
var package = YooAssets.TryGetPackage(packageName);
|
|
var package = YooAssets.TryGetPackage(packageName);
|
|
if (package == null)
|
|
if (package == null)
|
|
{
|
|
{
|
|
@@ -82,7 +66,7 @@ namespace GFGGame
|
|
else if (playMode == EPlayMode.HostPlayMode)
|
|
else if (playMode == EPlayMode.HostPlayMode)
|
|
{
|
|
{
|
|
// 联机运行模式
|
|
// 联机运行模式
|
|
- string defaultHostServer = GetHostServerURL(PackageName_GameLogic);
|
|
|
|
|
|
+ string defaultHostServer = GetHostServerURL(DefaultPackage);
|
|
string fallbackHostServer = defaultHostServer;
|
|
string fallbackHostServer = defaultHostServer;
|
|
var createParameters = new HostPlayModeParameters();
|
|
var createParameters = new HostPlayModeParameters();
|
|
//createParameters.DecryptionServices = new GameDecryptionServices();
|
|
//createParameters.DecryptionServices = new GameDecryptionServices();
|
|
@@ -98,24 +82,6 @@ namespace GFGGame
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private IEnumerator InitGameArtPackage()
|
|
|
|
- {
|
|
|
|
- InitializationOperation initializationOperation = null;
|
|
|
|
- var package = YooAssets.CreatePackage(PackageName_GameArt);
|
|
|
|
- string defaultHostServer = GetHostServerURL(PackageName_GameArt);
|
|
|
|
- string fallbackHostServer = defaultHostServer;
|
|
|
|
- var createParameters = new HostPlayModeParameters();
|
|
|
|
- //createParameters.DecryptionServices = new GameDecryptionServices();
|
|
|
|
- createParameters.QueryServices = new GameQueryServices();
|
|
|
|
- createParameters.RemoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
|
|
|
- initializationOperation = package.InitializeAsync(createParameters);
|
|
|
|
- yield return initializationOperation;
|
|
|
|
- if (initializationOperation.Status != EOperationStatus.Succeed)
|
|
|
|
- {
|
|
|
|
- Debug.LogWarning($"{initializationOperation.Error}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private IEnumerator GetStaticVersion(string packageName)
|
|
private IEnumerator GetStaticVersion(string packageName)
|
|
{
|
|
{
|
|
var package = YooAssets.GetPackage(packageName);
|
|
var package = YooAssets.GetPackage(packageName);
|
|
@@ -145,20 +111,19 @@ namespace GFGGame
|
|
Debug.LogWarning(operation.Error);
|
|
Debug.LogWarning(operation.Error);
|
|
Alert.Show("更新版本信息失败,请检测网络链接后重试。")
|
|
Alert.Show("更新版本信息失败,请检测网络链接后重试。")
|
|
.SetLeftButton(true, "重试", (data) => { StartCoroutine(UpdateManifest(packageName)); });
|
|
.SetLeftButton(true, "重试", (data) => { StartCoroutine(UpdateManifest(packageName)); });
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- void CreateDownloader(string packageName)
|
|
|
|
|
|
+ private void CreateDownloader(string packageName)
|
|
{
|
|
{
|
|
int downloadingMaxNum = 10;
|
|
int downloadingMaxNum = 10;
|
|
int failedTryAgain = 3;
|
|
int failedTryAgain = 3;
|
|
ResourcePackage package = YooAssets.GetPackage(packageName);
|
|
ResourcePackage package = YooAssets.GetPackage(packageName);
|
|
- var downloaderOperation = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
|
|
|
|
- VersionController.Instance.Downloader = downloaderOperation;
|
|
|
|
|
|
+ var downloaderOperation = package.CreateResourceDownloader(new string[] { "preload" }, downloadingMaxNum, failedTryAgain);
|
|
|
|
|
|
if (downloaderOperation.TotalDownloadCount == 0)
|
|
if (downloaderOperation.TotalDownloadCount == 0)
|
|
{
|
|
{
|
|
- OnPackageDownloadCompleted(packageName);
|
|
|
|
|
|
+ LauncherController.OnVersionCompleted();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -172,7 +137,7 @@ namespace GFGGame
|
|
float sizeMB = totalDownloadBytes / 1048576f;
|
|
float sizeMB = totalDownloadBytes / 1048576f;
|
|
sizeMB = Mathf.Clamp(sizeMB, 0.1f, float.MaxValue);
|
|
sizeMB = Mathf.Clamp(sizeMB, 0.1f, float.MaxValue);
|
|
string totalSizeMB = sizeMB.ToString("f1");
|
|
string totalSizeMB = sizeMB.ToString("f1");
|
|
- string message = $"游戏有新的版本,{packageName}需要更新{totalSizeMB}MB大小的内容";
|
|
|
|
|
|
+ string message = $"游戏有新的内容,{packageName}需要更新{totalSizeMB}MB大小的内容";
|
|
Alert.Show(message)
|
|
Alert.Show(message)
|
|
.SetLeftButton(true, "更新", (data) =>
|
|
.SetLeftButton(true, "更新", (data) =>
|
|
{
|
|
{
|
|
@@ -211,28 +176,6 @@ namespace GFGGame
|
|
});
|
|
});
|
|
yield break;
|
|
yield break;
|
|
}
|
|
}
|
|
- OnPackageDownloadCompleted(packageName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void OnPackageDownloadCompleted(string packageNameCompleted)
|
|
|
|
- {
|
|
|
|
- if(packageNameCompleted != null)
|
|
|
|
- {
|
|
|
|
- packageStateDic[packageNameCompleted] = true;
|
|
|
|
- }
|
|
|
|
- //if(updateVersions != null)
|
|
|
|
- //{
|
|
|
|
- // updateVersions.Override();
|
|
|
|
- //}
|
|
|
|
- foreach (var packageName in packageNameArr)
|
|
|
|
- {
|
|
|
|
- packageStateDic.TryGetValue(packageName, out bool done);
|
|
|
|
- if(!done)
|
|
|
|
- {
|
|
|
|
- CreateDownloader(packageName);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
LauncherController.OnVersionCompleted();
|
|
LauncherController.OnVersionCompleted();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -241,7 +184,7 @@ namespace GFGGame
|
|
/// </summary>
|
|
/// </summary>
|
|
private string GetHostServerURL(string packageName)
|
|
private string GetHostServerURL(string packageName)
|
|
{
|
|
{
|
|
- string hostServerIP = "http://127.0.0.1";
|
|
|
|
|
|
+ string hostServerIP = "http://10.108.64.127";
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
#if UNITY_EDITOR
|
|
if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.Android)
|
|
if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.Android)
|