Эх сурвалжийг харах

Merge branch 'master' of http://git.gfggame.com:3000/gfg/client

zhaoyang 3 жил өмнө
parent
commit
d4db94516c

+ 2 - 0
.gitignore

@@ -22,3 +22,5 @@
 /GameClient/Assets/StreamingAssets/Bundles_temp.meta
 /GameClient/Assets/StreamingAssets/Bundles_temp
 /GameClient/Assets/Game/CSShare
+/GameClient/Assets/StreamingAssets/Bundles
+/GameClient/BuildlesUnity

+ 1 - 1
FGUIProject/assets/DressUp/components/Component1.xml

@@ -6,7 +6,7 @@
     <image id="n28_pjip" name="n28" src="j48o3y" fileName="images/dz_hz_bxbx.png" xy="185,0">
       <gearDisplay controller="c1" pages="0"/>
     </image>
-    <text id="n30_pjip" name="txtNeedName" xy="-2,16" pivot="0.5,0" size="189,38" fontSize="27" color="#fff0db" align="center" vAlign="middle" autoClearText="true" text="孔雀东南飞·绣">
+    <text id="n30_pjip" name="txtNeedName" xy="1,8" size="200,39" fontSize="28" color="#fff0db" align="center" vAlign="middle" autoClearText="true" text="孔雀东南飞·绣">
       <gearDisplay controller="c1" pages="0"/>
     </text>
     <list id="n31_oixc" name="listTag" xy="18,18" size="220,38" layout="row" lineGap="12" colGap="22" defaultItem="ui://eg2y0ldpih7566" vAlign="middle" autoClearItems="true">

+ 54 - 25
GameClient/Assets/Editor/Xasset/Builds/BuildTask.cs

@@ -109,7 +109,7 @@ namespace VEngine.Editor.Builds
                     bundle = bundle.Substring(0, i);
                     bundle = bundle.ToLower();
 
-
+                    //以文件名标识分组
                     for (int j = 0; j < buildSetting.dirTypeList.Count; j++)
                     {
                         string str = buildSetting.dirTypeList[j];
@@ -127,6 +127,7 @@ namespace VEngine.Editor.Builds
                 }
 
             });
+            //以子文件夹为单位分组
             foreach (var dir in dirBundleList)
             {
                 var dirPath = Path.Combine(Environment.CurrentDirectory, dir);
@@ -165,6 +166,7 @@ namespace VEngine.Editor.Builds
             for (var i = 0; i < bundledAssets.Count; i++)
             {
                 var asset = bundledAssets[i];
+                //去重
                 if (!pathWithAssets.TryGetValue(asset.path, out var ba))
                 {
                     pathWithAssets[asset.path] = asset;
@@ -183,6 +185,7 @@ namespace VEngine.Editor.Builds
         {
             var bundles = new List<ManifestBundle>();
             var dictionary = new Dictionary<string, List<string>>();
+            //分组
             foreach (var asset in bundledAssets)
             {
                 if (!dictionary.TryGetValue(asset.bundle, out var assets))
@@ -199,9 +202,13 @@ namespace VEngine.Editor.Builds
                 assets.Add(asset.path);
             }
 
-            var outputPath = Settings.PlatformBuildPath;
+            var unityBuildPath = Settings.PlatformBuildPath;
+            if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
+            {
+                unityBuildPath = Settings.UnityBuildPath;
+            }
             if (bundles.Count <= 0) return;
-            var manifest = BuildPipeline.BuildAssetBundles(outputPath, bundles.ConvertAll(bundle =>
+            var manifest = BuildPipeline.BuildAssetBundles(unityBuildPath, bundles.ConvertAll(bundle =>
                     new AssetBundleBuild
                     {
                         assetNames = bundle.assets.ToArray(),
@@ -215,10 +222,11 @@ namespace VEngine.Editor.Builds
                 Debug.LogErrorFormat("Failed to build {0}.", name);
                 return;
             }
-            if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
-            {
-                CreateEncryptAssets(outputPath, outputPath, manifest, GFGGame.LauncherConfig.resKey);
-            }
+            //if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
+            //{
+            //    string buildPath = Settings.PlatformBuildPath;
+            //    CreateEncryptAssets(unityBuildPath, buildPath, manifest, GFGGame.LauncherConfig.resKey);
+            //}
             AfterBuildBundles(bundles, manifest);
         }
 
@@ -228,16 +236,16 @@ namespace VEngine.Editor.Builds
         /// </summary>
         public static void CreateEncryptAssets(string bundlePackagePath, string encryptAssetPath, AssetBundleManifest manifest, string secretKey)
         {
+            if (!Directory.Exists(encryptAssetPath))
+            {
+                Directory.CreateDirectory(encryptAssetPath);
+            }
             string[] assetBundles = manifest.GetAllAssetBundles();
             foreach (string assetBundle in assetBundles)
             {
                 string bundlePath = Path.Combine(bundlePackagePath, assetBundle);
                 byte[] encryptBytes = EncryptHelper.CreateEncryptData(bundlePath, secretKey);
-                if (!Directory.Exists(encryptAssetPath))
-                {
-                    Directory.CreateDirectory(encryptAssetPath);
-                }
-                using (FileStream fs = new FileStream(Path.Combine(bundlePackagePath, assetBundle), FileMode.OpenOrCreate))
+                using (FileStream fs = new FileStream(Path.Combine(encryptAssetPath, assetBundle), FileMode.OpenOrCreate))
                 {
                     fs.SetLength(0);
                     fs.Write(encryptBytes, 0, encryptBytes.Length);
@@ -245,6 +253,23 @@ namespace VEngine.Editor.Builds
             }
         }
 
+        /// <summary>
+        /// 创建加密的AssetBundle
+        /// </summary>
+        public static void CreateEncryptAsset(string unityBundlesPath, string bundlesPath, string unityBundle, string secretKey)
+        {
+            if (!Directory.Exists(bundlesPath))
+            {
+                Directory.CreateDirectory(bundlesPath);
+            }
+            string unityBundlePath = Path.Combine(unityBundlesPath, unityBundle);
+            byte[] encryptBytes = EncryptHelper.CreateEncryptData(unityBundlePath, secretKey);
+            using (FileStream fs = new FileStream(Path.Combine(bundlesPath, unityBundle), FileMode.OpenOrCreate))
+            {
+                fs.SetLength(0);
+                fs.Write(encryptBytes, 0, encryptBytes.Length);
+            }
+        }
 
         private string GetOriginBundle(string assetBundle)
         {
@@ -273,22 +298,12 @@ namespace VEngine.Editor.Builds
                 foreach (var assetBundle in assetBundles)
                 {
                     var originBundle = GetOriginBundle(assetBundle);
-                    var dependencies =
-                        Array.ConvertAll(manifest.GetAllDependencies(assetBundle), GetOriginBundle);
+                    var dependencies = Array.ConvertAll(manifest.GetAllDependencies(assetBundle), GetOriginBundle);
                     if (nameWithBundles.TryGetValue(originBundle, out var manifestBundle))
                     {
                         manifestBundle.nameWithAppendHash = assetBundle;
-                        manifestBundle.dependencies =
-                            Array.ConvertAll(dependencies, input => nameWithBundles[input].id);
-                        var file = Settings.GetBuildPath(assetBundle);
-                        if (File.Exists(file))
-                            using (var stream = File.OpenRead(file))
-                            {
-                                manifestBundle.size = stream.Length;
-                                manifestBundle.crc = Utility.ComputeCRC32(stream);
-                            }
-                        else
-                            Debug.LogErrorFormat("File not found: {0}", file);
+                        manifestBundle.dependencies = Array.ConvertAll(dependencies, input => nameWithBundles[input].id);
+                        
                     }
                     else
                     {
@@ -313,6 +328,20 @@ namespace VEngine.Editor.Builds
                     value.nameWithAppendHash != bundle.nameWithAppendHash)
                 {
                     newFiles.Add(bundle.nameWithAppendHash);
+                    if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
+                    {
+                        string buildPath = Settings.PlatformBuildPath;
+                        CreateEncryptAsset(Settings.UnityBuildPath, buildPath, bundle.nameWithAppendHash, GFGGame.LauncherConfig.resKey);
+                    }
+                    var file = Settings.GetBuildPath(bundle.nameWithAppendHash);
+                    if (File.Exists(file))
+                        using (var stream = File.OpenRead(file))
+                        {
+                            bundle.size = stream.Length;
+                            bundle.crc = Utility.ComputeCRC32(stream);
+                        }
+                    else
+                        Debug.LogErrorFormat("File not found: {0}", file);
                     newSize += bundle.size;
                 }
 

+ 11 - 0
GameClient/Assets/Editor/Xasset/Builds/Settings.cs

@@ -38,6 +38,17 @@ namespace VEngine.Editor.Builds
             }
         }
 
+        public static string UnityBuildPath
+        {
+            get
+            {
+                var dir = Utility.BuildlesUnityFolder + $"/{GetPlatformName()}";
+                if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
+
+                return dir;
+            }
+        }
+
         public static string BuildPlayerDataPath =>
             string.Format("{0}/{1}", Application.streamingAssetsPath, Utility.buildPath);
 

+ 4 - 0
GameClient/Assets/Editor/Xasset/MenuItems.cs

@@ -58,6 +58,10 @@ namespace VEngine.Editor
                 if (!Directory.Exists(directory)) return;
                 Directory.Delete(directory, true);
 
+                directory = Settings.UnityBuildPath;
+                if (!Directory.Exists(directory)) return;
+                Directory.Delete(directory, true);
+
                 ClearDownload();
             }
         }

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -118,7 +118,7 @@ namespace GFGGame
             }
             else
             {
-                if (skipGuide == 2 && LauncherConfig.netType == EnumNetType.LOCAL) GameGlobal.skipGuide = true;
+                if (skipGuide == 2) GameGlobal.skipGuide = true;
                 EnterGame();
 
             }

+ 3 - 4
GameClient/Assets/Game/HotUpdate/Controller/LogController.cs

@@ -2,7 +2,6 @@
 using UnityEngine;
 using UI.Common;
 using System;
-using static GFGGame.LauncherConfig;
 
 namespace GFGGame
 {
@@ -23,7 +22,7 @@ namespace GFGGame
             msgDic.Add(_all, new List<string>());
             msgDic.Add(_error, new List<string>());
             msgDic.Add(_log, new List<string>());
-            if (LauncherConfig.netType == EnumNetType.LOCAL)
+            if (LauncherConfig.onDebug == 1)
             {
                 this.CreatBtnLog();
             }
@@ -70,9 +69,9 @@ namespace GFGGame
                         _btnLog.m_c1.selectedIndex = 1;
                         _btnLog.target.alpha = 1;
                     }
-                    if (LauncherConfig.netType == EnumNetType.LOCAL)
+                    if (LauncherConfig.onDebug == 1)
                     {
-                        this.SetBtnLogVisable(true);
+                        ViewManager.Show(ViewName.LOG_VIEW);
                     }
                     break;
                 case LogType.Log:

+ 5 - 5
GameClient/Assets/Game/HotUpdate/Views/Card/CardFosterView.cs

@@ -166,12 +166,12 @@ namespace GFGGame
                 _cardObj = null;
             }
             string resPath = ResPathUtil.GetCardAnimationPath(_cardData.resources[_cardData.resIndex]);
-            // if (Versions.Contains(resPath))
-            // {
-            _cardObj = DressUpUtil.AddAnimationObj(resPath);
-            SceneController.AddObjectToView(_cardObj, _wrapper, _ui.m_comCard.m_comCardHolder.m_holder, resPath, out _cardObj, out _wrapper);
+             if (Versions.Contains(resPath))
+            {
+                _cardObj = DressUpUtil.AddAnimationObj(resPath);
+                SceneController.AddObjectToView(_cardObj, _wrapper, _ui.m_comCard.m_comCardHolder.m_holder, resPath, out _cardObj, out _wrapper);
 
-            // }
+            }
 
             if (_cardObj != null)
             {

+ 4 - 1
GameClient/Assets/Game/Launcher/LauncherConfig.cs

@@ -25,6 +25,7 @@ namespace GFGGame
         public static string logApiUrl;
         public static string apkVersion;
         public static int serverStatus;
+        public static int onDebug;
 
         public static string resKey
         {
@@ -46,7 +47,7 @@ namespace GFGGame
             cfgName = "cfg_dev";
 #elif PT_TEMP
             netType = EnumNetType.TEMP;
-            cfgName = "cfg_temp";
+            cfgName = "cfg_temp1";
 #else
             netType = EnumNetType.LOCAL;
             cfgName = "cfg_local";
@@ -67,6 +68,7 @@ namespace GFGGame
             LauncherConfig.apkVersion = result.apkVersion;
             LauncherConfig.serverStatus = int.Parse(result.serverStatus);
             LauncherConfig.platformId = int.Parse(result.platformId);
+            LauncherConfig.onDebug = int.Parse(result.onDebug);
             ET.Log.Debug($"platformId {LauncherConfig.platformId}");
         }
 
@@ -79,6 +81,7 @@ namespace GFGGame
             public string apkVersion;
             public string serverStatus;
             public string platformId;
+            public string onDebug;
         }
 
     }

+ 0 - 1
GameClient/Assets/Game/Launcher/Version/VersionController.cs

@@ -83,7 +83,6 @@ namespace GFGGame
                 LauncherView.Instance.SetDesc($"正在计算更新内容大小...", $"{ totalCount - remainCount }/{totalCount}");
                 yield return getDownloadSize;
             }
-            Debug.Log("VersionController GetDownloadSize tips");
             if (getDownloadSize.totalSize > 0 || updateVersions.changed)
             {
                 string message = $"游戏有新的版本,需要更新{Utility.FormatBytes(getDownloadSize.totalSize)}大小的内容";

BIN
GameClient/Assets/ResIn/Config/excelConfig.sqlite.bytes


+ 35 - 15
GameClient/Assets/ThirdParty/Xasset/EncryptHelper.cs

@@ -34,7 +34,7 @@ namespace VEngine
             {
                 encryptData = new byte[fs.Length];
                 fs.Read(encryptData, 0, encryptData.Length);
-                for (int i = 0; i < encryptData.Length; i++)
+                for (int i = 0; i < key.Length; i++)
                 {
                     encryptData[i] = (byte)(encryptData[i] ^ key[i % key.Length]);
                 }
@@ -47,33 +47,53 @@ namespace VEngine
         /// </summary>
         internal static byte[] GetDecryptData(string filePath, char[] secretKey = null)
         {
+            //Logger.I($"GetDecryptData filePath : {filePath} secretKey : {secretKey}");
             byte[] encryptData;
-            using (UnityWebRequest webRequest = UnityWebRequest.Get(filePath))
+            if (filePath.IndexOf("storage/emulated") > 0)
             {
-                webRequest.SendWebRequest();
-                while (!webRequest.isDone) { }
+                encryptData = File.ReadAllBytes(filePath);
+                if (secretKey != null)
+                {
+                    for (int i = 0; i < secretKey.Length; i++)
+                    {
+                        encryptData[i] = (byte)(encryptData[i] ^ secretKey[i % secretKey.Length]);
+                    }
+                }
+            }
+            else
+            {
+                using (UnityWebRequest webRequest = UnityWebRequest.Get(filePath))
+                {
+                    webRequest.SendWebRequest();
+                    while (!webRequest.isDone) { }
 #if UNITY_2020_1_OR_NEWER
-                if (webRequest.result == UnityWebRequest.Result.Success)
+                    //Logger.I($"GetDecryptData filePath : 1 webRequest.isDone : {webRequest.isDone} webRequest.result : {webRequest.result}");
+                    if (webRequest.result == UnityWebRequest.Result.Success)
 #else
+                    Logger.I($"GetDecryptData filePath : 2");
                 if (string.IsNullOrEmpty(webRequest.error))
 #endif
-                {
-                    encryptData = webRequest.downloadHandler.data;
-                    if (secretKey != null)
                     {
-                        for (int i = 0; i < encryptData.Length; i++)
+                        //Logger.I($"GetDecryptData filePath : 3");
+                        encryptData = webRequest.downloadHandler.data;
+                        if (secretKey != null)
                         {
-                            encryptData[i] = (byte)(encryptData[i] ^ secretKey[i % secretKey.Length]);
+                            for (int i = 0; i < secretKey.Length; i++)
+                            {
+                                encryptData[i] = (byte)(encryptData[i] ^ secretKey[i % secretKey.Length]);
+                            }
                         }
                     }
-                }
-                else
-                {
-                    encryptData = null;
+                    else
+                    {
+                        //Logger.I($"GetDecryptData filePath : 4");
+                        encryptData = null;
+                    }
                 }
             }
             return encryptData;
         }
+
     }
-    
+
 }

+ 2 - 0
GameClient/Assets/ThirdParty/Xasset/Runtime/Utilitys/Utility.cs

@@ -6,6 +6,8 @@ namespace VEngine
     public static class Utility
     {
         public static string buildPath = "Bundles";
+        //unity原生build出来的AB资源文件夹名称
+        public static string BuildlesUnityFolder = "BuildlesUnity";
 
         public const string unsupportedPlatform = "Unsupported";