Browse Source

装备开发

liao 4 months ago
parent
commit
480295158a
1 changed files with 39 additions and 10 deletions
  1. 39 10
      Assets/Scripts/GameLogic/Equipment/EquipmentController.cs

+ 39 - 10
Assets/Scripts/GameLogic/Equipment/EquipmentController.cs

@@ -85,13 +85,30 @@ namespace GameLogic.Equipment
         /// <param name="zy"></param>
         public void EquipZyEqs(int zy)
         {
-            if (zyEqDic.TryGetValue(zy, out equipZyEqDic))
+            if (zyEqDic.TryGetValue(zy, out var bwDic))
             {
-                // List<ItemInfo> eqList = zyEqDic[zy];
-                // foreach (ItemInfo eqItemInfo in eqList)
-                // {
-                //     
-                // }
+                foreach (KeyValuePair<int, List<ItemInfo>> keyValuePair in bwDic)
+                {
+                    ItemInfo bestBwEq = null;
+                    foreach (ItemInfo bwItem in keyValuePair.Value)
+                    {
+                        bwItem.eqInfo.isEquip = false;
+                        if (bestBwEq == null)
+                        {
+                            bestBwEq = bwItem;
+                            continue;
+                        }
+
+                        if (bwItem.eqInfo.Attack > bestBwEq.eqInfo.Attack ||
+                            bwItem.eqInfo.Defense > bestBwEq.eqInfo.Defense ||
+                            bwItem.eqInfo.Hp > bestBwEq.eqInfo.Hp)
+                        {
+                            bestBwEq = bwItem;
+                        }
+                    }
+                    if (bestBwEq != null) 
+                        bestBwEq.eqInfo.isEquip = true;
+                }
             }
         }
         
@@ -106,17 +123,29 @@ namespace GameLogic.Equipment
             int bw = eqItemInfo.eqInfo.basicEquipConfig.Type;
             if (zyEqDic.TryGetValue(pro, out var bwDic))
             {
-                
-                if (bwDic.ContainsKey(bw))
+
+
+
+                if (bwDic.TryGetValue(bw, out var eqBwList))
                 {
-                    bwDic[bw].Add(eqItemInfo);
+                    eqBwList.Add(eqItemInfo);
                 }
                 else
                 {
-                    List<ItemInfo> eqBwList = new List<ItemInfo>();
+                    eqBwList = new List<ItemInfo>();
                     eqBwList.Add(eqItemInfo);
                     bwDic.Add(bw, eqBwList);
                 }
+                // if (bwDic.ContainsKey(bw))
+                // {
+                //     bwDic[bw].Add(eqItemInfo);
+                // }
+                // else
+                // {
+                //     List<ItemInfo> eqBwList = new List<ItemInfo>();
+                //     eqBwList.Add(eqItemInfo);
+                //     bwDic.Add(bw, eqBwList);
+                // }
             }
             else
             {