Sfoglia il codice sorgente

下载模块修改

123 1 anno fa
parent
commit
a0b5f1b6c4

File diff suppressed because it is too large
+ 486 - 89
Assets/Content/Fonts/VAGRoundedStdRegularSDF.asset


+ 5 - 5
Assets/Lua/Core/PlatformPack.lua

@@ -1,9 +1,9 @@
 local PlatformPack = {
-	URL_KEY = 'http://101.43.46.101:81//',
-	SERVERLIST_URL = 'http://101.43.46.101:81//serverlist',
-	NOTIFY_URL = 'http://101.43.46.101:88//res/TestServerNotice/',
-	SPECIAL_INFO_URL = 'http://101.43.46.101:81//channel',
-	CUSTOMER_SERVICE_INFO_URL = 'http://101.43.46.101:81//vipService',
+	URL_KEY = 'http://43.248.187.68:81//',
+	SERVERLIST_URL = 'http://43.248.187.68:81//serverlist',
+	NOTIFY_URL = 'http://43.248.187.68:88//res/NoticeNew/',
+	SPECIAL_INFO_URL = 'http://43.248.187.68:81//channel',
+	CUSTOMER_SERVICE_INFO_URL = 'http://43.248.187.68:81//vipService',
 }
 
 return PlatformPack

+ 26 - 4
Assets/Src/Core/DownLoad/AssetDownloader.cs

@@ -12,6 +12,8 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
     private List<DownloadDataEntity> downloadDataEntities;
 
     private List<DownloadDataEntity> downloadSuccessDataEntities;
+    private List<DownloadDataEntity> downloadErrDataEntities;
+
     private int curTaskNum;
     private int maxTasknum;
 
@@ -59,10 +61,14 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         tasks = new Dictionary<DownloadTask, bool>(maxTasknum);
         downloadDataEntities = new List<DownloadDataEntity>();
         downloadSuccessDataEntities = new List<DownloadDataEntity>();
-
+        downloadErrDataEntities = new List<DownloadDataEntity>();
         for (int i = 0; i < maxTasknum; i++)
         {
-            DownloadTask task = new DownloadTask();
+            GameObject go = new GameObject("DownloadTask_"+i, typeof(DownloadTask));
+            DontDestroyOnLoad(go);
+            go.transform.SetParent(transform);
+           
+            DownloadTask task = go.GetComponent<DownloadTask>();
             task.Callback = TaskCallback;
             tasks.Add(task, true);
         }
@@ -168,7 +174,8 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         SetTaskState(task, false);
         if (task.SetUrl())
         {
-            StartCoroutine(task.Task());
+            // StartCoroutine(task.Task());
+            task.StartTask();
         }
 
     }
@@ -185,6 +192,13 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         else if (task.State == DownloadTaskState.Error)
         {
             task.CurDownloadEntity.Callback?.Invoke(null);
+            task.CurDownloadEntity.DownloadErrCount++;
+            task.CurDownloadEntity.State = DownloadTaskState.None;
+            if (task.CurDownloadEntity.DownloadErrCount >= 3)
+            {
+                OnDownloadErr(task.CurDownloadEntity);
+                Debug.Log("下载失败:" + task.CurDownloadEntity.FullName);
+            }
         }
         SetTaskState(task, true);
     }
@@ -243,12 +257,20 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         downloadSuccessDataEntities.Add(entity);
         downloadDataEntities.Remove(entity);
     }
+    private void OnDownloadErr(DownloadDataEntity entity)
+    {
+        downloadErrDataEntities.Add(entity);
+        downloadDataEntities.Remove(entity);
+    }
     public bool HasIdleTask()
     {
         return curTaskNum < maxTasknum;
     }
 
-
+    public bool HasTask()
+    {
+        return downloadDataEntities.Count > 0;
+    }
     public bool HasNotDownloadedEntity()
     {
         return downloadDataEntities != null && downloadDataEntities.Count > 0;

+ 6 - 2
Assets/Src/Core/DownLoad/DownloadDataEntity.cs

@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
+[Serializable]
 public class DownloadDataEntity : GameData<DownloadDataEntity>
 {
     public string FullName;
@@ -17,6 +18,8 @@ public class DownloadDataEntity : GameData<DownloadDataEntity>
 
     public DownloadTaskState State;
 
+    public int DownloadErrCount;
+
     public Action<DownloadTask> Callback;
     public Action<DownloadTask> UpDateCallback;
     public override string FlieName()
@@ -29,8 +32,9 @@ public class DownloadDataEntity : GameData<DownloadDataEntity>
         FullName = "";
         MD5 = "";
         Size = 0;
-       // Version = "";
-        State = DownloadTaskState.None;
+        // Version = "";
+        DownloadErrCount = 0;
+         State = DownloadTaskState.None;
     }
     private static void OnCsvLoad(CsvReader csvReader)
     {

+ 37 - 12
Assets/Src/Core/DownLoad/DownloadMgr.cs

@@ -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;
 

+ 9 - 3
Assets/Src/Core/DownLoad/DownloadTask.cs

@@ -13,7 +13,7 @@ public enum DownloadTaskState
     Error,
 }
 
-public class DownloadTask
+public class DownloadTask : MonoBehaviour
 {
 
 
@@ -23,9 +23,10 @@ public class DownloadTask
 
     public Action<DownloadTask> Callback { get; set; }
 
-   
+   [SerializeField]
     public DownloadDataEntity CurDownloadEntity { get; set; }
 
+    [SerializeField]
     public float CurLoadProgress { get; private set; }
     public ulong downloadSize;
 
@@ -69,7 +70,12 @@ public class DownloadTask
 
         return ret;
     }
-    
+
+    public void StartTask()
+    {
+        StartCoroutine(Task());
+    }
+
     public IEnumerator Task()
     {
         if (State == DownloadTaskState.Downloading)

+ 3 - 3
Assets/Src/GameLogic/LaunchLoadMgr.cs

@@ -115,7 +115,7 @@ public class LaunchLoadMgr
     {
         DownloadMgr.Instance.Init();
         DownloadMgr.Instance.CheckVersion();
-        SetLoadDes("查更新");
+        SetLoadDes("查更新");
         SetLoadPrecent(0);
         int pre = 0;
         yield return new WaitUntil(() =>
@@ -139,7 +139,7 @@ public class LaunchLoadMgr
 
         if (DownloadMgr.Instance.CheckNeedDownload())
         {
-            SetLoadDes("資源更新");
+            SetLoadDes("资源下载");
             SetLoadPrecent(0);
             yield return new WaitUntil(() =>
             {
@@ -156,7 +156,7 @@ public class LaunchLoadMgr
                     SetLoadPrecent((int)press);
                     string tstr = (tsize / (1024 * 1024)).ToString("f2");
                     string dstr = (dsize / (1024 * 1024)).ToString("f2");
-                    SetLoadDes($"資源更新:{dsize}m/{tstr}m");
+                    SetLoadDes($"资源下载:{dstr}m/{tstr}m");
                 }
 
                 return isFinish;

+ 12 - 9
ProjectSettings/ProjectSettings.asset

@@ -17,7 +17,7 @@ PlayerSettings:
   defaultCursor: {fileID: 0}
   cursorHotspot: {x: 0, y: 0}
   m_SplashScreenBackgroundColor: {r: 1, g: 1, b: 1, a: 1}
-  m_ShowUnitySplashScreen: 0
+  m_ShowUnitySplashScreen: 1
   m_ShowUnitySplashLogo: 1
   m_SplashScreenOverlayOpacity: 1
   m_SplashScreenAnimation: 0
@@ -39,9 +39,12 @@ PlayerSettings:
     y: 0
     width: 1
     height: 1
-  m_SplashScreenLogos: []
-  m_VirtualRealitySplashScreen: {fileID: 2800000, guid: f8d525a61ebf6c94682727cb97feeaa3,
-    type: 3}
+  m_SplashScreenLogos:
+  - logo: {fileID: 21300000, guid: f8d525a61ebf6c94682727cb97feeaa3, type: 3}
+    duration: 2
+  - logo: {fileID: 21300000, guid: 5dbb0c14d9cbf754ca68dc0c1b8d51ff, type: 3}
+    duration: 2
+  m_VirtualRealitySplashScreen: {fileID: 0}
   m_HolographicTrackingLossScreen: {fileID: 0}
   defaultScreenWidth: 480
   defaultScreenHeight: 800
@@ -172,7 +175,7 @@ PlayerSettings:
   AndroidTargetSdkVersion: 34
   AndroidPreferredInstallLocation: 1
   aotOptions: 
-  stripEngineCode: 1
+  stripEngineCode: 0
   iPhoneStrippingLevel: 0
   iPhoneScriptCallOptimization: 0
   ForceInternetPermission: 0
@@ -247,11 +250,11 @@ PlayerSettings:
   templateDefaultScene: Assets/Scenes/SampleScene.unity
   useCustomMainManifest: 1
   useCustomLauncherManifest: 0
-  useCustomMainGradleTemplate: 0
+  useCustomMainGradleTemplate: 1
   useCustomLauncherGradleManifest: 0
   useCustomBaseGradleTemplate: 0
-  useCustomGradlePropertiesTemplate: 0
-  useCustomProguardFile: 0
+  useCustomGradlePropertiesTemplate: 1
+  useCustomProguardFile: 1
   AndroidTargetArchitectures: 3
   AndroidTargetDevices: 0
   AndroidSplashScreenScale: 0
@@ -846,7 +849,7 @@ PlayerSettings:
   webGLDecompressionFallback: 1
   webGLPowerPreference: 1
   scriptingDefineSymbols:
-    Android: USE_LUA;VUPLEX_CCU;BUGLY;FPS_DISABLE;GAME_DEBUG;GAME_ONE
+    Android: USE_LUA;VUPLEX_CCU;BUGLY;FPS_DISABLE
     Standalone: USE_LUA;VUPLEX_CCU
     WebGL: USE_LUA;VUPLEX_CCU
     iPhone: USE_LUA;VUPLEX_CCU

+ 1 - 1
ProtocolGen/proto/login.proto

@@ -2776,7 +2776,7 @@ message SCPayInfoGetAck {
     int32 error                                         = 1; //错误码
     int32 goods_id                                      = 2;//
     int32 goods_type                                    = 3;
-    string goods_name                                   = 4; //Name|callackUr
+    string goods_name                                   = 4; //ID|Name|callackUrl
     uint64 cp_order_id                                  = 5; //产品订单号
     float amount                                        = 6; //支付总额
     int32 count                                         = 7; //购买数量

Some files were not shown because too many files changed in this diff