123 1 rok temu
rodzic
commit
9127cede42

+ 8 - 8
Assets/Lua/Config/ActivitiesTiredChargeCfg.lua

@@ -35,7 +35,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=5,
     ['Name']='累儲328',
     ['RechargeAmount']=328,
-    ['Reward']={{175,1000},{513,1},{687,1},{135,1},{134,1}},
+    ['Reward']={{175,500},{513,1},{687,1},{135,1},{134,1}},
     ['Day']=1,
     ['Index']=5,
     },
@@ -43,7 +43,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=6,
     ['Name']='累儲648',
     ['RechargeAmount']=648,
-    ['Reward']={{175,1000},{513,1},{523,1},{141,3},{139,1}},
+    ['Reward']={{175,800},{513,1},{523,1},{141,3},{139,1}},
     ['Day']=1,
     ['Index']=6,
     },
@@ -51,7 +51,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=7,
     ['Name']='累儲900',
     ['RechargeAmount']=900,
-    ['Reward']={{175,2000},{520,1},{607,2},{139,1},{138,1}},
+    ['Reward']={{175,1000},{520,1},{607,2},{139,1},{138,1}},
     ['Day']=1,
     ['Index']=7,
     },
@@ -59,7 +59,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=8,
     ['Name']='累儲1298',
     ['RechargeAmount']=1298,
-    ['Reward']={{175,3000},{520,2},{523,1},{608,1},{141,3}},
+    ['Reward']={{175,2000},{520,2},{523,1},{608,1},{141,3}},
     ['Day']=1,
     ['Index']=8,
     },
@@ -67,7 +67,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=9,
     ['Name']='累儲2000',
     ['RechargeAmount']=2000,
-    ['Reward']={{175,5000},{520,2},{523,1},{688,1},{138,2}},
+    ['Reward']={{175,3000},{520,2},{523,1},{688,1},{138,2}},
     ['Day']=1,
     ['Index']=9,
     },
@@ -363,7 +363,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=46,
     ['Name']='累儲7000',
     ['RechargeAmount']=7000,
-    ['Reward']={{523,2},{520,4},{138,10},{139,10},{529,10}},
+    ['Reward']={{175,5000},{523,2},{520,4},{138,10},{139,10},{529,10}},
     ['Day']=1,
     ['Index']=10,
   },
@@ -371,7 +371,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=47,
     ['Name']='累儲10000',
     ['RechargeAmount']=10000,
-    ['Reward']={{611,2},{139,20},{138,15},{2,4000000}},
+    ['Reward']={{175,8000},{611,2},{139,20},{138,15},{2,4000000}},
     ['Day']=1,
     ['Index']=11,
   },
@@ -379,7 +379,7 @@ local ActivitiesTiredChargeCfg = {
     ['Id']=48,
     ['Name']='累儲20000',
     ['RechargeAmount']=20000,
-    ['Reward']={{611,3},{139,30},{138,20},{2,5000000}},
+    ['Reward']={{175,10000},{611,3},{139,30},{138,20},{2,5000000}},
     ['Day']=1,
     ['Index']=12,
   },

+ 7 - 6
Assets/Src/Core/DownLoad/AssetDownloader.cs

@@ -83,10 +83,10 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         Debug.Log($"url = {url}");
         UnityWebRequest webRqst = UnityWebRequest.Get(url);
         float timeOut = Time.time;
-
+        webRqst.timeout = 5;
         UnityWebRequestAsyncOperation asyncOperation = webRqst.SendWebRequest();
         float progress = 0;
-
+       
         while (!webRqst.isDone)
         {
             if (progress < webRqst.downloadProgress)
@@ -172,7 +172,7 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
     {
 
         SetTaskState(task, false);
-        if (task.SetUrl())
+        if (task.SetUrl(task.CurDownloadEntity.Url))
         {
             // StartCoroutine(task.Task());
             task.StartTask();
@@ -191,10 +191,11 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         }
         else if (task.State == DownloadTaskState.Error)
         {
-            task.CurDownloadEntity.Callback?.Invoke(null);
+            task.CurDownloadEntity.State = DownloadTaskState.Error;
+            task.CurDownloadEntity.Callback?.Invoke(task);
             task.CurDownloadEntity.DownloadErrCount++;
             task.CurDownloadEntity.State = DownloadTaskState.None;
-            if (task.CurDownloadEntity.DownloadErrCount >= 3)
+            if (task.CurDownloadEntity.DownloadErrCount >= 10)
             {
                 OnDownloadErr(task.CurDownloadEntity);
                 Debug.Log("下载失败:" + task.CurDownloadEntity.FullName);
@@ -227,7 +228,7 @@ public class AssetDownloader : SingletonMono<AssetDownloader>
         int size = downloadDataEntities.Count;
         for (int i = 0; i < size; i++)
         {
-            if (downloadDataEntities[i].State == DownloadTaskState.None)
+            if (downloadDataEntities[i].State == DownloadTaskState.None )
             {
                 entity = downloadDataEntities[i];
                 break;

+ 3 - 0
Assets/Src/Core/DownLoad/DownloadDataEntity.cs

@@ -20,6 +20,8 @@ public class DownloadDataEntity : GameData<DownloadDataEntity>
 
     public int DownloadErrCount;
 
+    public string Url; 
+
     public Action<DownloadTask> Callback;
     public Action<DownloadTask> UpDateCallback;
     public override string FlieName()
@@ -32,6 +34,7 @@ public class DownloadDataEntity : GameData<DownloadDataEntity>
         FullName = "";
         MD5 = "";
         Size = 0;
+        Url = "";
         // Version = "";
         DownloadErrCount = 0;
          State = DownloadTaskState.None;

+ 64 - 54
Assets/Src/Core/DownLoad/DownloadMgr.cs

@@ -83,6 +83,8 @@ public class DownloadMgr : Singleton<DownloadMgr>
 
     private int tryGetVersionCount;
     public bool isQiangDownload;
+
+    public string ResVersion { get; private set; }
     public override void Init()
     {
         InitField();
@@ -123,7 +125,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
 #elif CN_I7GAME_ZHUAN
           return "http://43.248.186.74:88/";
 #elif CN_I7GAME_0_1
-        return "http://weix.vvfyj.cn/";//return "http://103.239.245.64:88/"; //
+         return "http://103.239.245.64:88/"; // "http://weix.vvfyj.cn/";//
 #elif GAME_DEBUG
          return "http://110.40.223.119:88/";
 #else
@@ -178,21 +180,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
     {
         if (!isInited)
         {
-            //            //downloadBaseUrl = "http://cxzcdn.hkhappygame.com/";//"http://165.154.29.92:88/"; //http://cxzcdn.hkhappygame.com/res/
-            //            //downloadBaseUrl = "http://127.0.0.1:8060/";//"http://127.0.0.1:8060/";//
-            //#if GAME_DEBUG
-            //            downloadBaseUrl = "http://110.40.223.119:88/";
-            //            downloadUrl = downloadBaseUrl + "res/TestServerRes/";
-            //#else
-            //            downloadBaseUrl = "http://cxzcdn.hkhappygame.com/";
-            //#if UNITY_IOS
-            //            downloadUrl = downloadBaseUrl + "res/IosRes/";
-            //#else
-            //            downloadUrl = downloadBaseUrl + "res/AndroidNewRes/";
-            //#endif
-            //#endif
-
-
+           
             downloadUrl = GetDownloadUrl();
 
 
@@ -217,6 +205,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
             totalSize = 0;
             tryGetVersionCount = 0;
             isQiangDownload = true;
+            ResVersion = "0.0.0.0";
         }
     }
     //
@@ -273,38 +262,32 @@ public class DownloadMgr : Singleton<DownloadMgr>
 
     private void StartCheck()
     {
-        AssetDownloader.Instance.DownLoadFileByCoroutine(GetRemoteUrl(versionFileName), webRqst =>
+        ReadDataFromFile(versionFileName, lVdatas =>
         {
-            tryGetVersionCount++;
-            if (webRqst == null)
+            if (lVdatas!=  null)
             {
-                if (isQiangDownload)
-                {
-                    CheckVersion();
-                }
-                else
-                {
-                    CheckFinish = true;
-                    DowmloadError = true;
-                }
-              
-                return;
+                ResVersion = Encoding.UTF8.GetString(lVdatas);
             }
-            byte[] data = webRqst.downloadHandler.data;
-
-            //versionData = new byte[data.Length];
-            //data.CopyTo(versionData,0);
-            string version = Encoding.UTF8.GetString(data);
-            Debug.Log("服务器 version = " + version);
-            versionData = version;
 
-            ReadDataFromFile(versionFileName, lVdatas =>
+            AssetDownloader.Instance.DownLoadFileByCoroutine(GetRemoteUrl(versionFileName), webRqst =>
             {
-                //OnloadedVersion(lVdatas, version);
+                tryGetVersionCount++;
+                if (webRqst == null)
+                {
+                    SetCheckFinishAddDownError();
+                    return;
+                }
+                byte[] data = webRqst.downloadHandler.data;
+
+                string version = Encoding.UTF8.GetString(data);
+                Debug.Log("服务器 version = " + version);
+                versionData = version;
                 OnloadedLocalVersion(lVdatas, version);
-            }, true);
-        });
 
+            });
+
+        }, true);
+        
     }
 
     public void DownLoadRemoteRes()
@@ -368,7 +351,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
             //AssetDownloader.Instance.CancelDownLoad = true;
             return;
         }
-        //Debug.Log($"下载:{downloadingSize}/{task.CurDownloadEntity.Size}    进度:{task.CurLoadProgress*100}%");
+        Log($"下载:{task.downloadSize}/{task.CurDownloadEntity.Size}    进度:{task.CurLoadProgress*100}%");
         //downloadingSize = task.downloadSize;
         if (!downloadingList.ContainsKey(task.CurDownloadEntity))
         {
@@ -379,12 +362,28 @@ public class DownloadMgr : Singleton<DownloadMgr>
             downloadingList[task.CurDownloadEntity] = task.downloadSize;
         }
     }
+    public void Log(string str)
+    {
+#if UNITY_EDITOR
+        Debug.Log(str);
+#endif
+    }
     private void DownloadedCallback(DownloadTask task)
     {
-        if (task == null)
+        if (task == null || task.State == DownloadTaskState.Error)
         {
             //DowmloadError = true;
             //AssetDownloader.Instance.CancelDownLoad = true;
+            if (task != null &&task.CurDownloadEntity.DownloadErrCount >= 3)
+            {
+                task.CurDownloadEntity.Url = GetDownloadUrl() + task.CurDownloadEntity.FullName;
+
+               Log("重新设置Url = " + task.CurDownloadEntity.Url);
+            }
+            else if (task != null && task.CurDownloadEntity.DownloadErrCount >= 10)
+            {
+                DowmloadError = true;
+            }
             return;
         }
 
@@ -436,8 +435,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
          {
              if (webRqst == null)
              {
-                 CheckFinish = true;
-                 DowmloadError = true;
+                 SetCheckFinishAddDownError();
                  return;
              }
              byte[] data = webRqst.downloadHandler.data;
@@ -481,6 +479,19 @@ public class DownloadMgr : Singleton<DownloadMgr>
         CheckFinish = true;
     }
 
+
+    private void SetCheckFinishAddDownError()
+    {
+        if (isQiangDownload  && tryGetVersionCount <= 10)
+        {
+            CheckVersion();
+        }
+        else
+        {
+            CheckFinish = true;
+            DowmloadError = true;
+        }
+    }
     private string GetLocalResPath()
     {
         string localPath = FileSystem.LocalDocumentPath;
@@ -508,7 +519,6 @@ public class DownloadMgr : Singleton<DownloadMgr>
         }
         
 
-       
         VersionCode lVersionCode = lVersionstr;//本地 local version
         VersionCode RVersionCode = version;// 远端 version
 
@@ -529,7 +539,7 @@ public class DownloadMgr : Singleton<DownloadMgr>
             SVersionCode = SVersionstr;
 
             VersionCode localMaxCode = lVersionCode > SVersionCode ? lVersionCode : SVersionCode;
-
+            ResVersion = localMaxCode;
             if (localMaxCode == RVersionCode)
             {
                 Debug.Log($"lVersionstr =  {lVersionstr}  SVersionstr = {SVersionstr}  =====  version = {version}   不需要更新");
@@ -828,18 +838,18 @@ public class DownloadMgr : Singleton<DownloadMgr>
 
     public void Free()
     {
-        //string savepath = localFilePath + downloadedAssetsFileName;
-        //FileHelper.DeleteFile(savepath);
+       
         if (!DowmloadError)
         {
-            if( !string.IsNullOrEmpty(versionData))
+            if (!string.IsNullOrEmpty(versionData))
+            {
                 FileHelper.WirteStringToFile(localFilePath + versionFileName, versionData);
-            //PlayerPrefs.SetString(versionFileName, versionData);
-            //if(mainfestData!=null)
-            //   FileHelper.WirteToFile(LocalFilePath + assetsFileName, mainfestData.downloadHandler.data);
+                ResVersion = versionData;
+            }
+                   
             if (remoteResList.Count > 0)
             {
-                //Debug.Log($" ============= remoteResList.Count = {remoteResList.Count}" );
+              
                 CsvWriter<DownloadDataEntity> csvWriter = new CsvWriter<DownloadDataEntity>(LocalFilePath + assetsFileName, "", remoteResList, downloadFormatInfo);
                 csvWriter.Write();
             }          

+ 14 - 20
Assets/Src/Core/DownLoad/DownloadTask.cs

@@ -55,6 +55,12 @@ public class DownloadTask : MonoBehaviour
     public bool SetUrl(string url = "")
     {
         bool ret = true;
+
+        if (webRqst!= null)
+        {
+            webRqst.Dispose();
+            webRqst = null;
+        }
         if (string.IsNullOrEmpty(url) && CurDownloadEntity != null)
         {
             webRqst = UnityWebRequest.Get(DownloadMgr.Instance.DownloadUrl + CurDownloadEntity.FullName);
@@ -67,7 +73,7 @@ public class DownloadTask : MonoBehaviour
         {
             ret = false;
         }
-
+        webRqst.timeout = 5;
         return ret;
     }
 
@@ -86,15 +92,6 @@ public class DownloadTask : MonoBehaviour
       
       
         string savePath = DownloadMgr.Instance.LocalFilePath + CurDownloadEntity.FullName;
-        //FileStream fs = new FileStream(savePath, FileMode.OpenOrCreate);
-        //if (fs == null)
-        //{
-        //    State = DownloadTaskState.Error;
-        //    Callback?.Invoke(this);
-        //    yield break;
-        //}
-       
-
 
         UnityWebRequestAsyncOperation asyncOperation = webRqst.SendWebRequest();
         yield return null;
@@ -108,18 +105,16 @@ public class DownloadTask : MonoBehaviour
                 timeOut = Time.time;
                 CurLoadProgress = webRqst.downloadProgress;
 
-                //int count = (int)(webRqst.downloadedBytes - downloadSize);
-                //fs.Write(webRqst.downloadHandler.data,(int)downloadSize, count);
-
+             
                 downloadSize = webRqst.downloadedBytes;
                 CurDownloadEntity.UpDateCallback?.Invoke(this);
             }
             if (Time.time - timeOut > DownloadMgr.TimeOut)
-            {
+            {           
                 Debug.LogWarning("下载超时!!!");
                 //fs.Close();
                 State = DownloadTaskState.Error;
-                Callback?.Invoke(this);
+                Callback?.Invoke(this);            
                 yield break;
             }
             yield return null;
@@ -127,15 +122,12 @@ public class DownloadTask : MonoBehaviour
         CurLoadProgress = webRqst.downloadProgress;
         downloadSize = webRqst.downloadedBytes;
         CurDownloadEntity.UpDateCallback?.Invoke(this);
-        //yield return asyncOperation;
-        //fs.Flush();
-        //fs.Close();
+     
 
         if (webRqst != null && webRqst.error == null)
         {
             Debug.Log($"[{CurDownloadEntity.FullName}] 下载完成");
-            State = DownloadTaskState.DownloadSuccess;
-            //FileHelper.WriteToFileAsync( savePath,webRqst.downloadHandler.data,()=> { Callback?.Invoke(this); });
+            State = DownloadTaskState.DownloadSuccess;      
             FileHelper.WirteToFile( savePath,webRqst.downloadHandler.data);
             Callback?.Invoke(this);
         }
@@ -145,5 +137,7 @@ public class DownloadTask : MonoBehaviour
             Debug.Log($"下载失败;Error = {webRqst.error}   ===  {CurDownloadEntity.FullName} ");
             Callback?.Invoke(this);
         }
+        webRqst.Dispose();
+        
     }
 }

+ 4 - 20
Assets/Src/GameLogic/GameMgr.cs

@@ -251,28 +251,12 @@ public class GameMgr : SingletonMono<GameMgr>
         InitBugly();
     }
 
-    private void CheckVersion()
+    public void CheckVersion()
     {
         mGameVersion = Application.version;
-        int versionCodeInt = 0;// Wenting.Lebian.LeBianSDK.instance.GetResVerCode();
-        VersionCode versionCode1;
-        if (versionCodeInt <= 0)
-        {
-            versionCode1 = mGameVersion;
-        }
-        else
-        {
-            versionCode1 = (VersionCode)(uint)versionCodeInt;
-        }
-        VersionCode versionCode2 = AssetsMgr.Instance.resVersionCode;
-        if (versionCode1 < versionCode2)
-        {
-            mResVersion = versionCode2.ToString();
-        }
-        else
-        {
-            mResVersion = versionCode1.ToString();
-        }
+      
+         mResVersion = DownloadMgr.Instance.ResVersion;//AssetsMgr.Instance.resVersionCode;
+       
     }
 
     void InitBugly()

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

@@ -169,6 +169,9 @@ public class LaunchLoadMgr
         }
 
         DownloadMgr.Instance.Free();
+        GameMgr.Instance.CheckVersion();
+        //m_AppVolTxt.text = GameMgr.Instance.GameVersion;
+        //m_ResVolTxt.text = DownloadMgr.Instance.ResVersion;
         //m_LoadingRootGo.SetActive(false);
         //SetLoadEffectShowState(false);
         SetLoadDes("");

+ 1 - 1
ProjectSettings/ProjectSettings.asset

@@ -163,7 +163,7 @@ PlayerSettings:
     iPhone: com.ycgame.cxz.ios
   buildNumber:
     Standalone: 0
-    iPhone: 0.1.0.2
+    iPhone: 0.1.0.3
     tvOS: 0
   overrideDefaultApplicationIdentifier: 1
   AndroidBundleVersionCode: 1000006