|
|
@@ -51,6 +51,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
public string LocalFilePath { get => localFilePath; }
|
|
|
|
|
|
private List<DownloadDataEntity> needDownloadList;
|
|
|
+ private Dictionary<DownloadDataEntity,ulong> downloadingList;
|
|
|
private List<DownloadDataEntity> downloadSucessList;
|
|
|
private List<DownloadDataEntity> remoteResList;
|
|
|
private Dictionary<string, DownloadDataEntity> localResMap;
|
|
|
@@ -67,7 +68,8 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
|
|
|
private ulong downloadSize;
|
|
|
private ulong downloadingSize;
|
|
|
- public ulong DownloadSize { get => downloadSize + downloadingSize; }
|
|
|
+
|
|
|
+ public ulong DownloadSize { get => downloadSize + GetDownloadingSize(); }
|
|
|
private ulong totalSize;//总大小
|
|
|
public ulong TotalSize { get => totalSize; }
|
|
|
public bool CheckFinish { get;private set; }
|
|
|
@@ -84,7 +86,15 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
InitField();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private ulong GetDownloadingSize()
|
|
|
+ {
|
|
|
+ downloadingSize = 0;
|
|
|
+ foreach (var item in downloadingList)
|
|
|
+ {
|
|
|
+ downloadingSize += item.Value;
|
|
|
+ }
|
|
|
+ return downloadingSize;
|
|
|
+ }
|
|
|
private string GetIOSDownloadPath()
|
|
|
{
|
|
|
return "res/IosRes/";
|
|
|
@@ -95,10 +105,12 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
|
|
|
private string GetAndroidDownloadPath()
|
|
|
{
|
|
|
-#if GAME_DEBUG
|
|
|
+#if GAME_ONE
|
|
|
+ return "res/WDAndroidRes/";
|
|
|
+#elif GAME_DEBUG
|
|
|
return "res/TestServerRes/";
|
|
|
#else
|
|
|
- return "res/AndroidNewRes/";
|
|
|
+ return "res/WDAndroidRes/";
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -110,7 +122,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
return "http://110.40.223.119:88/";
|
|
|
#else
|
|
|
|
|
|
- return "http://cxzcdn.hkhappygame.com/";
|
|
|
+ return "http://cdn.yishanyou.com/";
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -145,7 +157,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
downloadUrl = GetDownloadUrl();
|
|
|
|
|
|
|
|
|
- downloadTaskMaxNum = 1;
|
|
|
+ downloadTaskMaxNum = 5;
|
|
|
localFilePath = GetLocalResPath();//FileSystem.LocalDocumentPath;
|
|
|
|
|
|
|
|
|
@@ -154,6 +166,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
downloadedAssetsFileName = "downloaded";
|
|
|
needDownloadList = new List<DownloadDataEntity>(100);
|
|
|
downloadSucessList = new List<DownloadDataEntity>(100);
|
|
|
+ downloadingList = new Dictionary<DownloadDataEntity,ulong>(downloadTaskMaxNum);
|
|
|
remoteResList = new List<DownloadDataEntity>(1024);
|
|
|
localResMap = new Dictionary<string, DownloadDataEntity>(1024);
|
|
|
remoteResMap = new Dictionary<string, DownloadDataEntity>(1024);
|
|
|
@@ -244,7 +257,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
ret = false;
|
|
|
}
|
|
|
}
|
|
|
- return ret || DowmloadError;
|
|
|
+ return ret || DowmloadError || !AssetDownloader.Instance.HasTask();
|
|
|
}
|
|
|
|
|
|
public bool CheckNeedDownload()
|
|
|
@@ -255,19 +268,27 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
{
|
|
|
if (task == null)
|
|
|
{
|
|
|
- DowmloadError = true;
|
|
|
- AssetDownloader.Instance.CancelDownLoad = true;
|
|
|
+ // DowmloadError = true;
|
|
|
+ //AssetDownloader.Instance.CancelDownLoad = true;
|
|
|
return;
|
|
|
}
|
|
|
//Debug.Log($"下载:{downloadingSize}/{task.CurDownloadEntity.Size} 进度:{task.CurLoadProgress*100}%");
|
|
|
- downloadingSize = task.downloadSize;
|
|
|
+ //downloadingSize = task.downloadSize;
|
|
|
+ if (!downloadingList.ContainsKey(task.CurDownloadEntity))
|
|
|
+ {
|
|
|
+ downloadingList.Add(task.CurDownloadEntity, task.downloadSize);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ downloadingList[task.CurDownloadEntity] = task.downloadSize;
|
|
|
+ }
|
|
|
}
|
|
|
private void DownloadedCallback(DownloadTask task)
|
|
|
{
|
|
|
if (task == null)
|
|
|
{
|
|
|
- DowmloadError = true;
|
|
|
- AssetDownloader.Instance.CancelDownLoad = true;
|
|
|
+ //DowmloadError = true;
|
|
|
+ //AssetDownloader.Instance.CancelDownLoad = true;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -282,6 +303,10 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
{
|
|
|
downloadSucessList.Add(task.CurDownloadEntity);
|
|
|
}
|
|
|
+ if (downloadingList.ContainsKey(task.CurDownloadEntity))
|
|
|
+ {
|
|
|
+ downloadingList.Remove(task.CurDownloadEntity);
|
|
|
+ }
|
|
|
downloadingSize = 0;
|
|
|
downloadSize += task.downloadSize;
|
|
|
|