guodong vor 2 Jahren
Ursprung
Commit
81bcd34a78
1 geänderte Dateien mit 45 neuen und 45 gelöschten Zeilen
  1. 45 45
      GameClient/Assets/Game/HotUpdate/DressUp/DressUpObj.cs

+ 45 - 45
GameClient/Assets/Game/HotUpdate/DressUp/DressUpObj.cs

@@ -89,7 +89,9 @@ namespace GFGGame
             }
             else
             {
-                UpdateRoleView();
+                var tempData = DressUpDataClone();
+                TakeOffAll();
+                PutOnDressUpData(tempData);
             }
         }
 
@@ -281,12 +283,6 @@ namespace GFGGame
             }
         }
 
-        //刷新视图,用于新设置sceneobj后的初始显示
-        private void UpdateRoleView()
-        {
-            PutOnDressUpData(DressUpDataClone());
-        }
-
         /// <summary>
         /// 尝试穿戴配置套装
         /// </summary>
@@ -297,11 +293,7 @@ namespace GFGGame
         /// <param name="CheckOwn">是否只显示主角拥有的部件</param>
         public void PutOnSuitCfg(int id, bool tryShowAction, int[] excludeType = null, bool showOptional = true, bool CheckOwn = true)
         {
-            if (_dressUpData.suitId == id)
-            {
-                return;
-            }
-            TakeOffAll(false);
+            bool oldIsAction = IsAction;
             _dressUpData.suitId = id;
             bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(_dressUpData.suitId);
             _dressUpData.actionId = (hasSuitActionRes && tryShowAction) ? id : 0;
@@ -309,13 +301,14 @@ namespace GFGGame
             List<int> items = new List<int>(suitCfg.partsArr);
             if (showOptional)
             {
-
                 if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
                 {
                     items.AddRange(suitCfg.partsOptionalArr);
                 }
             }
             int subType = 0;
+            //找到要穿的散件
+            List<int> targetItemList = new List<int>();
             foreach (int itemId in items)
             {
                 if (!CheckOwn || DressUpMenuItemDataManager.CheckHasItem(itemId))
@@ -326,11 +319,12 @@ namespace GFGGame
                     {
                         if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
                         {
-                            AddOrRemove(itemId, false, DressUpOption.Add);
+                            targetItemList.Add(itemId);
                         }
                     }
                 }
             }
+            CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
             checkDefaultItem();
         }
 
@@ -410,19 +404,18 @@ namespace GFGGame
         }
 
         //穿戴一组换装数据
-        public void PutOnDressUpData(DressUpData dressUpData)
+        public void PutOnDressUpData(DressUpData targetDressUpData)
         {
-            TakeOffAll(false);
-            _dressUpData.suitId = dressUpData.suitId;
-            _dressUpData.actionId = dressUpData.actionId;
-            if (dressUpData.bgId > 0)
-            {
-                AddOrRemove(dressUpData.bgId, false);
-            }
-            foreach (int itemID in dressUpData.itemList)
+            bool oldIsAction = IsAction;
+            _dressUpData.suitId = targetDressUpData.suitId;
+            _dressUpData.actionId = targetDressUpData.actionId;
+            var targetItemList = new List<int>();
+            targetItemList.AddRange(targetDressUpData.itemList);
+            if (targetDressUpData.bgId > 0)
             {
-                AddOrRemove(itemID, false, DressUpOption.Add);
+                targetItemList.Add(targetDressUpData.bgId);
             }
+            CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
             checkDefaultItem();
 
         }
@@ -439,27 +432,7 @@ namespace GFGGame
             bool oldIsAction = IsAction;
             _dressUpData.suitId = 0;
             _dressUpData.actionId = 0;
-            foreach (int itemID in itemList)
-            {
-                if(!targetItemList.Contains(itemID))
-                {
-                    //移除不穿的部件
-                    AddOrRemove(itemID, false, DressUpOption.Remove);
-                }
-                else if(oldIsAction)
-                {
-                    //当从动画形态切换时
-                    if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID))
-                    {
-                        //对非场景类型移除,重穿
-                        AddOrRemove(itemID, false, DressUpOption.Remove);
-                    }
-                }
-            }
-            foreach (int itemID in targetItemList)
-            {
-                AddOrRemove(itemID, false, DressUpOption.Add);
-            }
+            CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
             checkDefaultItem();
         }
 
@@ -515,6 +488,33 @@ namespace GFGGame
             }
         }
 
+        //与身上的散件对比差异然后添加
+        private void CompareAndAddItemList(bool oldIsAction, bool newIsAction, List<int> targetItemList)
+        {
+            bool actionStatusChanged = (oldIsAction && !newIsAction) || (!oldIsAction && newIsAction);
+            foreach (int itemID in itemList)
+            {
+                if (!targetItemList.Contains(itemID))
+                {
+                    //移除不穿的部件
+                    AddOrRemove(itemID, false, DressUpOption.Remove);
+                }
+                else if (actionStatusChanged)
+                {
+                    //当动画形态切换时
+                    if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID))
+                    {
+                        //非场景类型重穿
+                        AddOrRemove(itemID, false, DressUpOption.Remove);
+                    }
+                }
+            }
+            foreach (int itemID in targetItemList)
+            {
+                AddOrRemove(itemID, false, DressUpOption.Add);
+            }
+        }
+
         //检测当前穿戴是否是一件完整套装,且只穿了一件套装,返回套装id
         private int CheckCurDressIsSuit()
         {