From 2bfcee1e0ac2fb7a4bfacd552d3a5053c614dccf Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期四, 01 十一月 2018 11:17:22 +0800
Subject: [PATCH] 3335 资源下载优先级别更新。

---
 System/AssetVersion/AssetVersionUtility.cs                      |   25 ++++
 Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta          |    2 
 System/Dungeon/DungeonModel.cs                                  |   12 +-
 Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs |   81 ++++++----------
 Fight/MapTransferUtility.cs                                     |    7 
 Fight/Stage/StageManager.cs                                     |    4 
 Core/GameEngine/Model/Config/PriorBundleConfig.cs               |   53 +++++-----
 System/AssetVersion/InGameDownLoad.cs                           |   50 ++++-----
 System/AssetVersion/AssetVersion.cs                             |   16 --
 9 files changed, 118 insertions(+), 132 deletions(-)

diff --git a/Core/GameEngine/Model/Config/PriorBundleConfig.cs b/Core/GameEngine/Model/Config/PriorBundleConfig.cs
index 7cf9998..2ad589e 100644
--- a/Core/GameEngine/Model/Config/PriorBundleConfig.cs
+++ b/Core/GameEngine/Model/Config/PriorBundleConfig.cs
@@ -1,26 +1,27 @@
-锘�//--------------------------------------------------------
-//    [Author]:			绗簩涓栫晫
-//    [  Date ]:		   Wednesday, July 25, 2018
-//--------------------------------------------------------
-
-using UnityEngine;
-using System;
-
-namespace TableConfig {
-
-    
+锘�//--------------------------------------------------------
+//    [Author]:			绗簩涓栫晫
+//    [  Date ]:		   Thursday, November 01, 2018
+//--------------------------------------------------------
+
+using UnityEngine;
+using System;
+
+namespace TableConfig {
+
+    
 	public partial class PriorBundleConfig : ConfigBase {
 
 		public int id { get ; private set ; }
 		public string AssetABName { get ; private set; } 
 		public int AssetType { get ; private set ; }
-
+		public int Prior { get ; private set ; }
+
 		public override string getKey()
         {
             return id.ToString();
-        }
-
-		public override void Parse() {
+        }
+
+		public override void Parse() {
 			try
             {
                 id=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0; 
@@ -28,17 +29,19 @@
 				AssetABName = rawContents[1].Trim();
 			
 				AssetType=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0; 
+			
+				Prior=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0; 
             }
             catch (Exception ex)
             {
                 DebugEx.Log(ex);
-            }
-		}
-	
-	}
-
-}
-
-
-
-
+            }
+		}
+	
+	}
+
+}
+
+
+
+
diff --git a/Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta b/Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta
index 8909c4d..7c62f4a 100644
--- a/Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta
+++ b/Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta
@@ -1,6 +1,6 @@
 fileFormatVersion: 2
 guid: 949b242ddea04fe418ea4647b082dcb7
-timeCreated: 1532484855
+timeCreated: 1541037151
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2
diff --git a/Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs b/Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs
index 3e96360..fea7e4b 100644
--- a/Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs
+++ b/Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs
@@ -7,75 +7,32 @@
 {
     public partial class PriorBundleConfig : ConfigBase
     {
-        static List<string> m_Audios;
-        public static List<string> audios {
-            get {
-                if (!inited)
-                {
-                    Init();
-                }
-                return m_Audios;
-            }
-        }
-
-        static List<string> m_Effects;
-        public static List<string> effects {
-            get {
-                if (!inited)
-                {
-                    Init();
-                }
-                return m_Effects;
-            }
-        }
-
-        static List<string> m_Scenes;
-        public static List<string> scenes {
-            get {
-                if (!inited)
-                {
-                    Init();
-                }
-                return m_Scenes;
-            }
-        }
-
-        static List<string> m_Mobs;
-        public static List<string> mobs {
-            get {
-                if (!inited)
-                {
-                    Init();
-                }
-                return m_Mobs;
-            }
-        }
+        static Dictionary<string, PriorBundleConfig> m_Audios = new Dictionary<string, PriorBundleConfig>();
+        static Dictionary<string, PriorBundleConfig> m_Effects = new Dictionary<string, PriorBundleConfig>();
+        static Dictionary<string, PriorBundleConfig> m_Scenes = new Dictionary<string, PriorBundleConfig>();
+        static Dictionary<string, PriorBundleConfig> m_Mobs = new Dictionary<string, PriorBundleConfig>();
 
         static bool inited = false;
 
         static void Init()
         {
             var values = Config.Instance.GetAllValues<PriorBundleConfig>();
-            m_Audios = new List<string>();
-            m_Effects = new List<string>();
-            m_Scenes = new List<string>();
-            m_Mobs = new List<string>();
 
             foreach (var value in values)
             {
                 switch (value.AssetType)
                 {
                     case 1:
-                        m_Scenes.Add(value.AssetABName.ToLower());
+                        m_Scenes[value.AssetABName.ToLower()] = value;
                         break;
                     case 2:
-                        m_Mobs.Add(value.AssetABName.ToLower());
+                        m_Mobs[value.AssetABName.ToLower()] = value;
                         break;
                     case 3:
-                        m_Audios.Add(value.AssetABName.ToLower());
+                        m_Audios[value.AssetABName.ToLower()] = value;
                         break;
                     case 4:
-                        m_Effects.Add(value.AssetABName.ToLower());
+                        m_Effects[value.AssetABName.ToLower()] = value;
                         break;
                 }
             }
@@ -83,6 +40,28 @@
             inited = true;
         }
 
+        public static int GetAssetPrior(AssetVersion.AssetCategory category, string fileName)
+        {
+            if (!inited)
+            {
+                Init();
+            }
+            fileName = fileName.ToLower();
+            switch (category)
+            {
+                case AssetVersion.AssetCategory.Scene:
+                    return m_Scenes.ContainsKey(fileName) ? m_Scenes[fileName].Prior : 100;
+                case AssetVersion.AssetCategory.Mob:
+                    return m_Mobs.ContainsKey(fileName) ? m_Mobs[fileName].Prior : 101;
+                case AssetVersion.AssetCategory.Effect:
+                    return m_Effects.ContainsKey(fileName) ? m_Effects[fileName].Prior : 102;
+                case AssetVersion.AssetCategory.Audio:
+                    return m_Audios.ContainsKey(fileName) ? m_Audios[fileName].Prior : 103;
+                default:
+                    return 0;
+            }
+
+        }
     }
 
 }
\ No newline at end of file
diff --git a/Fight/MapTransferUtility.cs b/Fight/MapTransferUtility.cs
index 2761c10..928a218 100644
--- a/Fight/MapTransferUtility.cs
+++ b/Fight/MapTransferUtility.cs
@@ -801,12 +801,11 @@
 
     public static bool Send_WorldTransfer(int mapId, Vector3 position, MapTransferType type, byte lineID = 255, int _npcId = 0)
     {
-        if (!AssetSource.sceneFromEditor && !AssetVersionUtility.IsUnpriorAssetDownLoadOk())
+        if (!AssetSource.sceneFromEditor)
         {
             var mapResConfig = DTCA127_tagMCStartChangeMap.GetMapResourcesConfig(mapId, 0);
-            var assetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
-
-            if (assetVersion != null && !assetVersion.IsPriorAsset())
+            var assetValid = AssetVersionUtility.IsAssetValid(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
+            if (!assetValid)
             {
                 InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                 return false;
diff --git a/Fight/Stage/StageManager.cs b/Fight/Stage/StageManager.cs
index 0faa26d..f2d2232 100644
--- a/Fight/Stage/StageManager.cs
+++ b/Fight/Stage/StageManager.cs
@@ -97,8 +97,8 @@
         }
         else
         {
-            var assetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
-            if (assetVersion != null && assetVersion.IsPriorAsset())
+            var assetValid = AssetVersionUtility.IsAssetValid(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
+            if (assetValid)
             {
                 SnxxzGame.Instance.StartCoroutine(LoadCoroutine<T>(stageId, mapResConfig.ID, mapResConfig.MapResources, true));
             }
diff --git a/System/AssetVersion/AssetVersion.cs b/System/AssetVersion/AssetVersion.cs
index 11a12b9..f27cceb 100644
--- a/System/AssetVersion/AssetVersion.cs
+++ b/System/AssetVersion/AssetVersion.cs
@@ -150,19 +150,9 @@
             }
             else
             {
-                switch (GetAssetCategory())
-                {
-                    case AssetCategory.Scene:
-                        return PriorBundleConfig.scenes.Contains(m_FileName);
-                    case AssetCategory.Mob:
-                        return PriorBundleConfig.mobs.Contains(m_FileName);
-                    case AssetCategory.Audio:
-                        return PriorBundleConfig.audios.Contains(m_FileName);
-                    case AssetCategory.Effect:
-                        return PriorBundleConfig.effects.Contains(m_FileName);
-                    default:
-                        return true;
-                }
+                var category = GetAssetCategory();
+                var prior = PriorBundleConfig.GetAssetPrior(category, m_FileName);
+                return prior <= 1;
             }
         }
         else
diff --git a/System/AssetVersion/AssetVersionUtility.cs b/System/AssetVersion/AssetVersionUtility.cs
index 50527a3..05dea9e 100644
--- a/System/AssetVersion/AssetVersionUtility.cs
+++ b/System/AssetVersion/AssetVersionUtility.cs
@@ -143,11 +143,11 @@
         return assetVersions;
     }
 
-    public static AssetVersion GetAssetVersion(string _assetBundleName)
+    public static AssetVersion GetAssetVersion(string assetKey)
     {
-        if (assetVersions.ContainsKey(_assetBundleName))
+        if (assetVersions.ContainsKey(assetKey))
         {
-            return assetVersions[_assetBundleName];
+            return assetVersions[assetKey];
         }
         else
         {
@@ -155,6 +155,25 @@
         }
     }
 
+    public static bool IsAssetValid(string assetKey)
+    {
+        if (assetVersions.ContainsKey(assetKey))
+        {
+            return assetVersions[assetKey].localValid;
+        }
+        else
+        {
+            if (VersionUtility.Instance.NeedDownAsset())
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+    }
+
     public static string GetAssetFilePath(string _assetKey)
     {
         var path = string.Empty;
diff --git a/System/AssetVersion/InGameDownLoad.cs b/System/AssetVersion/InGameDownLoad.cs
index dba7b55..4611786 100644
--- a/System/AssetVersion/InGameDownLoad.cs
+++ b/System/AssetVersion/InGameDownLoad.cs
@@ -16,10 +16,8 @@
 
     public bool inGameDownLoadAllow = false;
 
-    public float progress
-    {
-        get
-        {
+    public float progress {
+        get {
             return Mathf.Clamp01((float)showDownLoadedSize / showTotalSize);
         }
     }
@@ -34,11 +32,9 @@
     int totalCount = 0;
 
     int m_OkCount = 0;
-    int okCount
-    {
+    int okCount {
         get { return m_OkCount; }
-        set
-        {
+        set {
             m_OkCount = value;
         }
     }
@@ -53,11 +49,9 @@
     Action onDownLoadOk;
 
     Dominant m_DominantState = Dominant.None;
-    public Dominant dominantState
-    {
+    public Dominant dominantState {
         get { return m_DominantState; }
-        private set
-        {
+        private set {
             if (m_DominantState != value)
             {
                 m_DominantState = value;
@@ -70,11 +64,9 @@
     }
 
     State m_State = State.None;
-    public State state
-    {
+    public State state {
         get { return m_State; }
-        set
-        {
+        set {
             if (m_State != value)
             {
                 m_State = value;
@@ -91,8 +83,7 @@
 
     public List<Reward> rewards = new List<Reward>();
     public bool hasReward { get; private set; }
-    public string completeDownLoadAccount
-    {
+    public string completeDownLoadAccount {
         get { return LocalSave.GetString("InGameDownLoadCompleteAccount"); }
         set { LocalSave.SetString("InGameDownLoadCompleteAccount", value); }
     }
@@ -103,6 +94,7 @@
     {
         inGameDownLoadAllow = false;
         tasks = _tasks;
+        tasks.Sort(AssetDownLoadPriorCompare);
         onDownLoadOk = _onDownLoadOk;
 
         totalCount = tasks.Count;
@@ -246,7 +238,6 @@
         }
     }
 
-
     IEnumerator Co_StartDownLoad()
     {
         downLoadedSizeRecord += RemoteFile.TotalDownloadedSize;
@@ -347,11 +338,9 @@
 
     Clock netSwitchClock;
     NetworkReachability m_NetworkReachability = NetworkReachability.NotReachable;
-    NetworkReachability networkReachability
-    {
+    NetworkReachability networkReachability {
         get { return m_NetworkReachability; }
-        set
-        {
+        set {
             if (m_NetworkReachability != value)
             {
                 m_NetworkReachability = value;
@@ -388,11 +377,9 @@
 
 
     bool m_SimulateWifi = true;
-    public bool simulateWifi
-    {
+    public bool simulateWifi {
         get { return m_SimulateWifi; }
-        set
-        {
+        set {
             if (m_SimulateWifi != value)
             {
                 m_SimulateWifi = value;
@@ -539,6 +526,15 @@
         }
     }
 
+    private int AssetDownLoadPriorCompare(AssetVersion lhs, AssetVersion rhs)
+    {
+        var categoryA = lhs.GetAssetCategory();
+        var categoryB = rhs.GetAssetCategory();
+        var priorA = PriorBundleConfig.GetAssetPrior(categoryA, lhs.fileName);
+        var priorB = PriorBundleConfig.GetAssetPrior(categoryB, rhs.fileName);
+
+        return priorA < priorB ? -1 : 1;
+    }
 
     public struct Reward
     {
diff --git a/System/Dungeon/DungeonModel.cs b/System/Dungeon/DungeonModel.cs
index 73c03ab..83bb073 100644
--- a/System/Dungeon/DungeonModel.cs
+++ b/System/Dungeon/DungeonModel.cs
@@ -550,10 +550,10 @@
                 }
                 if (Index > -1)
                 {
-                    if (Index + 1 >=7)
+                    if (Index + 1 >= 7)
                     {
-                        if(7-mainModel.WaHuangHighestFloor>=0)
-                        mainModel.LayerNumber = 7 - mainModel.WaHuangHighestFloor;
+                        if (7 - mainModel.WaHuangHighestFloor >= 0)
+                            mainModel.LayerNumber = 7 - mainModel.WaHuangHighestFloor;
                     }
                     else
                     {
@@ -1174,12 +1174,12 @@
 
         public void RequestChallangeDungeon(int _dataMapId, int _lineId)
         {
-            if (!AssetSource.sceneFromEditor && !AssetVersionUtility.IsUnpriorAssetDownLoadOk())
+            if (!AssetSource.sceneFromEditor)
             {
                 var mapResConfig = DTCA127_tagMCStartChangeMap.GetMapResourcesConfig(_dataMapId, _lineId);
-                var assetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
+                var assetValid = AssetVersionUtility.IsAssetValid(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower()));
 
-                if (assetVersion != null && !assetVersion.IsPriorAsset())
+                if (!assetValid)
                 {
                     InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                     return;

--
Gitblit v1.8.0