140 lines
4.9 KiB
C#
140 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BF
|
|
{
|
|
public class LaunchRequester
|
|
{
|
|
public bool isNewPackage; // 是否是新包覆盖
|
|
public bool isHotUpdate; // 热更
|
|
public bool isAutoRepair; // 自动修复
|
|
public AssetBundle firstAb; // 首包
|
|
public string languageName; // 当前选择的多语言
|
|
public bool downloadLanguage; // 下载多语言
|
|
|
|
// public string persistentAbccMD5; // 持久化目录abConfig md5
|
|
public string persistentAbccVersion; // 持久化目录abConfig里的版本号
|
|
public string curVersionTempDir; // 当前版本对应的临时下载目录
|
|
|
|
public BFVersionInfo versionInfo; // 版本信息
|
|
|
|
public string firstChoiceCDN; // 首选cdn地址
|
|
public string backupCDN; // 备用cdn地址
|
|
|
|
public bool launchSucceed;
|
|
|
|
public AssetBundleConfigCollection streamingAbcc; // 包内abConfig
|
|
public AssetBundleConfigCollection persistentAbcc; // 持久化目录abConfig
|
|
public AssetBundleConfigCollection versionAbcc; // 热更版本abConfig
|
|
public byte[] streamingData; // 包内abConfig数据
|
|
public byte[] versionData; // 下载的abConfig数据
|
|
|
|
public List<AssetBundleConfig> preCheckMissingList; // 预检查丢失列表
|
|
public List<string> preCheckOverList; // 预检查冗余列表
|
|
public List<AssetBundleConfig> downloadList; // 下载列表
|
|
public List<string> deleteList; // 删除文件列表
|
|
|
|
public Action preCheckNextProcessAction; // 预检查下一处理阶段
|
|
|
|
public Action<string, string, Action<string>> FirstRequestAction { get; private set; } // 首次拉更新
|
|
|
|
public Action<int, Action> DialogAction { get; private set; } // 单选对话框
|
|
public Action<int, Action, Action> DialogComplexAction { get; private set; } // 多选对话框
|
|
public Action HideDialogAction { get; private set; } // 隐藏对话框
|
|
public Action<int, float> UpdateSilderAction { get; private set; } // 进度条
|
|
public Action HideSliderAction { get; private set; } // 隐藏进度条
|
|
|
|
public Action OnPreCheckEnd { get; private set; } // 当预检查完成
|
|
public Action<long> OnGetTotalLength { get; private set; } // 获取到更新总大小
|
|
public Action<long> OnDownloading { get; private set; } // 当前下载量更新
|
|
public Action OnLaunchSucc { get; private set; } // 启动成功
|
|
|
|
public LaunchRequester()
|
|
{
|
|
preCheckMissingList = new List<AssetBundleConfig>();
|
|
preCheckOverList = new List<string>();
|
|
downloadList = new List<AssetBundleConfig>();
|
|
deleteList = new List<string>();
|
|
|
|
AddLaunchSuccCallback(() =>
|
|
{
|
|
launchSucceed = true;
|
|
});
|
|
}
|
|
|
|
public void SetLanguageName(string languageName)
|
|
{
|
|
this.languageName = languageName;
|
|
}
|
|
|
|
public void SetFirstRequestAction(Action<string, string, Action<string>> action)
|
|
{
|
|
FirstRequestAction = action;
|
|
}
|
|
|
|
public void SetVersionInfo(string json)
|
|
{
|
|
versionInfo = JsonConvert.DeserializeObject<BFVersionInfo>(json);
|
|
}
|
|
|
|
public void SetShowDialogAction(Action<int, Action> action)
|
|
{
|
|
DialogAction = action;
|
|
}
|
|
|
|
public void SetShowDialogComplexAction(Action<int, Action, Action> action)
|
|
{
|
|
DialogComplexAction = action;
|
|
}
|
|
|
|
public void SetHideDialogAction(Action action)
|
|
{
|
|
HideDialogAction = action;
|
|
}
|
|
|
|
public void SetUpdateSliderAction(Action<int, float> action)
|
|
{
|
|
UpdateSilderAction = action;
|
|
}
|
|
|
|
public void SetHideSliderAction(Action action)
|
|
{
|
|
HideSliderAction = action;
|
|
}
|
|
|
|
public void SetPreCheckEndCallback(Action action)
|
|
{
|
|
OnPreCheckEnd = action;
|
|
}
|
|
|
|
public void SetGetTotalLengthCallback(Action<long> action)
|
|
{
|
|
OnGetTotalLength = action;
|
|
}
|
|
|
|
public void SetDownloadingCallback(Action<long> action)
|
|
{
|
|
OnDownloading = action;
|
|
}
|
|
|
|
public void AddLaunchSuccCallback(Action action)
|
|
{
|
|
OnLaunchSucc += action;
|
|
}
|
|
|
|
public void ClearLaunchSuccCallback()
|
|
{
|
|
OnLaunchSucc = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入预检查下一阶段
|
|
/// </summary>
|
|
public void PreCheckNextProcess()
|
|
{
|
|
preCheckNextProcessAction?.Invoke();
|
|
}
|
|
}
|
|
} |