|
|
@@ -56,11 +56,12 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
private List<DownloadDataEntity> remoteResList;
|
|
|
private Dictionary<string, DownloadDataEntity> localResMap;
|
|
|
private Dictionary<string, DownloadDataEntity> remoteResMap;
|
|
|
-
|
|
|
+
|
|
|
+ private Dictionary<string,DownLoadUrlCfg> downLoadUrlCfgs;
|
|
|
private bool isInited = false;
|
|
|
|
|
|
private GameDataFormatInfo downloadFormatInfo;
|
|
|
-
|
|
|
+ private DownLoadUrlCfg curUrlCfg;
|
|
|
private string versionFileName;
|
|
|
private string assetsFileName;
|
|
|
private string downloadedAssetsFileName;
|
|
|
@@ -135,7 +136,10 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
|
|
|
private string GetBaseUrl()
|
|
|
{
|
|
|
-
|
|
|
+ if (curUrlCfg != null)
|
|
|
+ {
|
|
|
+ return curUrlCfg.ServerUrl;
|
|
|
+ }
|
|
|
#if GAME_DEBUG
|
|
|
return "http://110.40.223.119:81/";
|
|
|
#else
|
|
|
@@ -151,6 +155,10 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
|
|
|
private string GetDownloadUrl()
|
|
|
{
|
|
|
+ if (curUrlCfg != null)
|
|
|
+ {
|
|
|
+ return curUrlCfg.BaseUrl + curUrlCfg.DownloadPath;
|
|
|
+ }
|
|
|
#if UNITY_IOS
|
|
|
return GetDownloadBaseUrl() + GetIOSDownloadPath();
|
|
|
#else
|
|
|
@@ -159,6 +167,10 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
}
|
|
|
private string GetDownloadUrlFormServer(string baseUrl)
|
|
|
{
|
|
|
+ if (curUrlCfg != null)
|
|
|
+ {
|
|
|
+ return baseUrl + curUrlCfg.DownloadPath;
|
|
|
+ }
|
|
|
#if UNITY_IOS
|
|
|
return baseUrl + GetIOSDownloadPath();
|
|
|
#else
|
|
|
@@ -191,8 +203,8 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
remoteResList = new List<DownloadDataEntity>(1024);
|
|
|
localResMap = new Dictionary<string, DownloadDataEntity>(1024);
|
|
|
remoteResMap = new Dictionary<string, DownloadDataEntity>(1024);
|
|
|
-
|
|
|
- isInited = true;
|
|
|
+ downLoadUrlCfgs = new Dictionary<string, DownLoadUrlCfg>();
|
|
|
+ isInited = true;
|
|
|
CheckFinish = false;
|
|
|
DowmloadError = false;
|
|
|
downloadSize = 0;
|
|
|
@@ -206,6 +218,11 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
//
|
|
|
private string GetPlatform()
|
|
|
{
|
|
|
+ if (curUrlCfg!= null)
|
|
|
+ {
|
|
|
+ return curUrlCfg.Platform;
|
|
|
+ }
|
|
|
+
|
|
|
#if UNITY_EDITOR
|
|
|
return "IOS";// "PC";
|
|
|
#else
|
|
|
@@ -219,6 +236,10 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
}
|
|
|
private string GetParam1()
|
|
|
{
|
|
|
+ if (curUrlCfg != null)
|
|
|
+ {
|
|
|
+ return curUrlCfg.Param1;
|
|
|
+ }
|
|
|
return "null";
|
|
|
}
|
|
|
public void CheckVersion()
|
|
|
@@ -264,7 +285,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
private void StartCheck()
|
|
|
{
|
|
|
ReadDataFromFile(versionFileName, lVdatas =>
|
|
|
@@ -433,6 +454,19 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
+ private List<DownLoadUrlCfg> SerizlizeUrlCfg(byte[] data)
|
|
|
+ {
|
|
|
+ if (data == null) return null;
|
|
|
+ CsvReader csvReader = new CsvReader("urlcfg", data,1,2,3);
|
|
|
+ if (downloadFormatInfo == null)
|
|
|
+ {
|
|
|
+ downloadFormatInfo = new GameDataFormatInfo(csvReader.Fields(), csvReader.Types());
|
|
|
+ }
|
|
|
+ DownLoadUrlCfg.OnCsvLoad(csvReader);
|
|
|
+ List<DownLoadUrlCfg> resList = DownLoadUrlCfg.AllData();
|
|
|
+ DownLoadUrlCfg.Clear();
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
private void GetRemoteResList()
|
|
|
{
|
|
|
string remoteversionpath = downloadUrl + assetsFileName;
|
|
|
@@ -875,4 +909,46 @@ public class DownloadMgr : Singleton<DownloadMgr>
|
|
|
//mainfestData = null;
|
|
|
AssetDownloader.Instance.ClearTasks();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public void InitUrlCfg()
|
|
|
+ {
|
|
|
+ List<DownLoadUrlCfg> loadUrlCfgs = SerizlizeUrlCfg(ConfigMgr.Instance.UrlDatas);
|
|
|
+
|
|
|
+ if (loadUrlCfgs == null) return;
|
|
|
+
|
|
|
+ for (int i = 0; i < loadUrlCfgs.Count; i++)
|
|
|
+ {
|
|
|
+ Log("Platform = " + loadUrlCfgs[i].Platform);
|
|
|
+ downLoadUrlCfgs.Add(loadUrlCfgs[i].Platform,loadUrlCfgs[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ curUrlCfg = GetCurUrlCfg();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private DownLoadUrlCfg GetCurUrlCfg()
|
|
|
+ {
|
|
|
+ DownLoadUrlCfg ret = null;
|
|
|
+
|
|
|
+ string platform = "GameDebug";
|
|
|
+
|
|
|
+#if GAME_DEBUG
|
|
|
+
|
|
|
+#else
|
|
|
+#if UNITY_ANDROID
|
|
|
+ platform = "Android";
|
|
|
+#else
|
|
|
+ platform = "IOS";
|
|
|
+#endif
|
|
|
+#endif
|
|
|
+
|
|
|
+ if (downLoadUrlCfgs.ContainsKey(platform))
|
|
|
+ {
|
|
|
+ ret = downLoadUrlCfgs[platform];
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
}
|