lcn 5 hónapja
szülő
commit
664e00c1eb

+ 59 - 5
Assets/Scripts/GameLogic/Equipment/EquipmentController.cs

@@ -1,9 +1,10 @@
 using System.Collections.Generic;
+using Codice.CM.Common;
 using Excel2Json;
 using Fort23.UTool;
-using GameLogic.Bag;
 using GameLogic.Player;
 using UnityEditor;
+using ItemInfo = GameLogic.Bag.ItemInfo;
 
 namespace GameLogic.Equipment
 {
@@ -90,9 +91,10 @@ namespace GameLogic.Equipment
                 foreach (KeyValuePair<int, List<ItemInfo>> keyValuePair in bwDic)
                 {
                     ItemInfo bestBwEq = null;
+                    //遍历完成后,可以把这个部位最好的装备找到
                     foreach (ItemInfo bwItem in keyValuePair.Value)
                     {
-                        bwItem.eqInfo.isEquip = false;
+                        // bwItem.eqInfo.isEquip = false;
                         if (bestBwEq == null)
                         {
                             bestBwEq = bwItem;
@@ -106,8 +108,43 @@ namespace GameLogic.Equipment
                             bestBwEq = bwItem;
                         }
                     }
-                    if (bestBwEq != null) 
+
+                    if (bestBwEq != null)
+                    {
                         bestBwEq.eqInfo.isEquip = true;
+                        if (equipZyEqDic.TryGetValue(zy, out var eqList))
+                        {
+                            bool isAdd = true;
+                            // 从后往前遍历,这样删除元素不会影响索引
+                            for (int i = eqList.Count - 1; i >= 0; i--)
+                            {
+                                ItemInfo itemInfo = eqList[i];
+                                if (itemInfo.eqInfo.basicEquipConfig.Type == bestBwEq.eqInfo.basicEquipConfig.Type)
+                                {
+
+                                    if (itemInfo.Equals(bestBwEq))
+                                    {
+                                        isAdd = false;
+                                    }
+                                    else
+                                    {
+                                        itemInfo.eqInfo.isEquip = false;
+                                        eqList.RemoveAt(i);
+                                    }
+                                    
+                                    break;
+                                }
+                            }
+
+                            if (isAdd)
+                            {
+                                eqList.Add(bestBwEq);    
+                            }
+
+                        }
+                        
+                    } 
+                        
                 }
             }
         }
@@ -166,8 +203,25 @@ namespace GameLogic.Equipment
             {
                 return;
             }
-            
-            int pro = eqItemInfo.eqInfo.basicEquipConfig.profession;
+
+            int zy = eqItemInfo.eqInfo.basicEquipConfig.profession;
+            int bw = eqItemInfo.eqInfo.basicEquipConfig.Type;
+
+            if (zyEqDic.TryGetValue(zy, out var bwDic))
+            {
+                if (bwDic.TryGetValue(bw, out var eqList))
+                {
+                    eqList.Remove(eqItemInfo);
+                }
+                else
+                {
+                    LogTool.Error("移除一个在背包不存在的(bw),装备: guid=" + eqItemInfo.guid + "   职业=" + zy);
+                }
+            }
+            else
+            {
+                LogTool.Error("移除一个在背包不存在的(zy),装备: guid=" + eqItemInfo.guid + "   职业=" + zy);
+            }
             
             // if (zyEqDic.ContainsKey(pro) && zyEqDic[pro].Contains(eqItemInfo))
             // {