From 3de702a97c97baafb6a0abafbc1abb74e1c3352b Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期三, 20 二月 2019 13:56:51 +0800
Subject: [PATCH] 3335 物品管理相关功能重构。

---
 System/KnapSack/Logic/ItemLogicUtility.cs |  103 ++++++++++++++++++++++-----------------------------
 1 files changed, 44 insertions(+), 59 deletions(-)

diff --git a/System/KnapSack/Logic/ItemLogicUtility.cs b/System/KnapSack/Logic/ItemLogicUtility.cs
index fb82969..54c591f 100644
--- a/System/KnapSack/Logic/ItemLogicUtility.cs
+++ b/System/KnapSack/Logic/ItemLogicUtility.cs
@@ -50,7 +50,7 @@
             {
                 if (putOnLimits[0] == 1)
                 {
-                    CheckPutOnPlace();
+                    CheckPutOnPlace(itemId);
                 }
                 else
                 {
@@ -69,7 +69,7 @@
             int[] uselimits = config.UseCondiType;
             if (uselimits == null || uselimits.Length < 1)
             {
-                CheckPutOnPlace();
+                CheckPutOnPlace(itemId);
                 return true;
             }
 
@@ -98,7 +98,7 @@
 
             if (wearable)
             {
-                CheckPutOnPlace();
+                CheckPutOnPlace(itemId);
             }
 
             return wearable;
@@ -334,8 +334,7 @@
                     {
                         ConfirmCancel.ShowPopConfirm(Language.Get("KnapS138"), Language.Get("KnapS139"), () =>
                         {
-
-                            CheckPutOnPlace();
+                            CheckPutOnPlace(selectedItem == null ? 0 : selectedItem.itemId);
                         });
                         PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshFreePoint;
                     }
@@ -346,26 +345,32 @@
         /// <summary>
         /// 妫�娴嬬┛鎴寸殑浣嶇疆瀵逛粰鍣ㄨ繘琛岀壒娈婂鐞�
         /// </summary>
-        private void CheckPutOnPlace()
+        private void CheckPutOnPlace(int itemId)
         {
+            var config = ItemConfig.Get(itemId);
+            if (config == null)
+            {
+                return;
+            }
+
             ItemModel putOnModel1 = null;
             ItemModel putOnModel2 = null;
             bool isSameEquip = false;
-            switch ((RoleEquipType)sendItemConfig.EquipPlace)
+            switch ((RoleEquipType)config.EquipPlace)
             {
                 case RoleEquipType.FairyCan:
                     isSameEquip = true;
-                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.Equip, sendItemConfig.EquipPlace);
+                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.Equip, config.EquipPlace);
                     putOnModel2 = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
                     break;
                 case RoleEquipType.JadeDynasty_Glove1:
                     isSameEquip = true;
-                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, sendItemConfig.EquipPlace);
+                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, config.EquipPlace);
                     putOnModel2 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Glove2);
                     break;
                 case RoleEquipType.JadeDynasty_Ring1:
                     isSameEquip = true;
-                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, sendItemConfig.EquipPlace);
+                    putOnModel1 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, config.EquipPlace);
                     putOnModel2 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Ring2);
                     break;
             }
@@ -379,7 +384,7 @@
                 }
             }
 
-            CheckSuitReplaceInfo(sendItemConfig.EquipPlace, selectedItem);
+            CheckSuitReplaceInfo(config.EquipPlace, selectedItem);
         }
 
         public void CheckSuitReplaceInfo(int equipPlace, ItemModel item)
@@ -536,10 +541,13 @@
                     break;
             }
 
-            if (putOnModel == null) return;
+            if (putOnModel == null)
+            {
+                return;
+            }
 
-            Dictionary<int, EquipmentInitialization> equipStrengthDic = strengthModel._EqInfo;
-            bool isPrompt = strengthModel.TheRatingPrompt(item.itemId);
+            var equipStrengthDic = strengthModel._EqInfo;
+            var isPrompt = strengthModel.TheRatingPrompt(item.itemId);
             if (isPrompt && !PlayerPrefs.HasKey(PlayerPackModel.StrengthAttrShift_RecordKey))
             {
                 LocalSave.SetBool(PlayerPackModel.StrengthAttrShift_RecordKey, true);
@@ -567,13 +575,14 @@
                     stones = existGem ? equipData.items : null;
                     break;
             }
-            int[] gemOpenLvs = packType == PackType.JadeDynastyItem ? itemTipsModel.jadeDynastyGemOpenLvs : itemTipsModel.gemOpenLvs;
+
+            var gemOpenLvs = packType == PackType.JadeDynastyItem ? itemTipsModel.jadeDynastyGemOpenLvs : itemTipsModel.gemOpenLvs;
             if (stones != null)
             {
                 int i = 0;
                 for (i = 0; i < stones.Length; i++)
                 {
-                    if (stones[i] != 0 && sendItemConfig.LV >= gemOpenLvs[0])
+                    if (stones[i] != 0 && item.config.LV >= gemOpenLvs[0])
                     {
                         SysNotifyMgr.Instance.ShowTip("SwitchEquip_Gem");
                         break;
@@ -581,13 +590,12 @@
                 }
             }
 
-            if (suitModel.IsPerfectGetSuitLv(sendItemConfig.ID, equipPlace))
+            if (suitModel.IsPerfectGetSuitLv(item.itemId, equipPlace))
             {
                 SysNotifyMgr.Instance.ShowTip("SwitchEquip_SuitPanel");
             }
 
-            WashProCount washPro = equipWashModel.GetWashEquipInfo(equipPlace);
-
+            var washPro = equipWashModel.GetWashEquipInfo(equipPlace);
             if (washPro != null)
             {
                 int i = 0;
@@ -605,7 +613,7 @@
         #endregion
 
         #region 鍙戦�佽劚涓嬭澶囩殑璇锋眰
-        public void PutOffEquip(ItemOperateType btnType, string guid)
+        public void PutOffEquip(string guid)
         {
             var item = playerPack.GetItemModelByGUID(guid);
             if (item == null)
@@ -684,7 +692,7 @@
         #endregion
 
         #region 鍙戦�佹斁鍏ヤ粨搴撹姹�
-        public void PutInWareHouse(ItemOperateType btnType, string guid)
+        public void PutInWareHouse(string guid)
         {
             var itemModel = playerPack.GetItemModelByGUID(guid);
             if (itemModel == null)
@@ -719,8 +727,8 @@
 
         #region 鍙戦�佷娇鐢ㄧ墿鍝佽姹�
 
-        public ItemModel useItemModel { get; set; }
-        public void UseItem(ItemOperateType btnType, int itemIndex)
+        public ItemModel useItemModel { get;  set; }
+        public void UseItem(int itemIndex)
         {
             var singlePack = playerPack.GetSinglePackModel(PackType.Item);
             if (singlePack == null)
@@ -1093,10 +1101,11 @@
         #endregion
 
         #region 鍙戦�佹媶鍒嗚姹�
-        public void OnClickSplitBtn(ItemOperateType btnType, string guid)
+        public void OnClickSplitBtn(string guid)
         {
             WindowCenter.Instance.Open<SplitWin>();
         }
+
         public void SplitItem(string guid, int splitCount)
         {
             if (string.IsNullOrEmpty(guid))
@@ -1129,7 +1138,7 @@
         #endregion
 
         #region 鍙戦�佷笂鏋惰姹� 
-        public void PutAwayItem(ItemOperateType btnType, string guid)
+        public void PutAwayItem(string guid)
         {
             var itemModel = playerPack.GetItemModelByGUID(guid);
             if (itemModel == null || itemModel.packType != PackType.Item)
@@ -1144,7 +1153,7 @@
         #endregion
 
         #region 鐐瑰嚮闀跺祵鎸夐挳 
-        public void GotoInlayItem(ItemOperateType btnType, string guid)
+        public void GotoInlayItem(string guid)
         {
             var model = playerPack.GetItemModelByGUID(guid);
             var packType = GeneralDefine.GetPackTypeByItemType(model.config.Type);
@@ -1161,24 +1170,24 @@
         #endregion
 
         #region 鐐瑰嚮鍚堟垚鎸夐挳 
-        public void GotoComposeItem(ItemOperateType btnType, int jumpId)
+        public void GotoComposeItem(int jumpId)
         {
             WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)jumpId);
         }
         #endregion
 
         #region 鍙戦�佸嚭鍞姹� 
-        public void SellItem(ItemOperateType btnType, ItemAttrData attrData)
+        public void SellItem( ItemAttrData attrData)
         {
             if (attrData.itemConfig.EquipPlace > 0 && attrData.itemConfig.EquipPlace <= (int)RoleEquipType.SpiritAnimal)
             {
                 bool isOverdue = modelInterface.IsOverdue(attrData.guid, attrData.itemConfig.ID, attrData.useDataDict);
                 bool isLimit = Math.Floor((double)attrData.itemConfig.JobLimit / 100) == PlayerDatas.Instance.baseData.Job
                     || attrData.itemConfig.JobLimit == 0 ? true : false;
-                ItemModel putModel = playerPack.GetItemModelByIndex(PackType.Equip, attrData.itemConfig.EquipPlace);
+                var putModel = playerPack.GetItemModelByIndex(PackType.Equip, attrData.itemConfig.EquipPlace);
                 if (attrData.itemConfig.EquipPlace == (int)RoleEquipType.FairyCan)
                 {
-                    ItemModel fairy2Model = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
+                    var fairy2Model = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
                     if (fairy2Model == null || putModel == null)
                     {
                         putModel = null;
@@ -1255,9 +1264,9 @@
         #endregion
 
         #region 鍙戦�佹媶瑙h姹�
-        public void DismantleItem(ItemOperateType btnType, ItemAttrData attrData)
+        public void DismantleItem(ItemAttrData attrData)
         {
-            List<int> dismantleReturnlist = attrData.GetUseDataModel((int)ItemUseDataKey.itemDecompound);
+            var dismantleReturnlist = attrData.GetUseDataModel((int)ItemUseDataKey.itemDecompound);
             int needGridCnt = 0;
             int fixedMatcnt = 0;
             int unfixedMatId = 0;
@@ -1315,44 +1324,20 @@
         #endregion
 
         #region 鍙戦�佺画璐硅姹� 
-        public void RenewalItem(ItemOperateType btnType, string guid)
+        public void RenewalItem(string guid)
         {
             GuardOverdueWin.guid = guid;
             WindowCenter.Instance.Open<GuardOverdueWin>();
         }
         #endregion
 
-        #region 瑙i攣鑳屽寘鏍煎瓙鏁版嵁
-        public int OpenCount
-        {
-            get; private set;
-        }
-
-        public PackType packType
-        {
-            get; private set;
-        }
-
-        public int Index
-        {
-            get; private set;
-        }
-
-        public void SetExtendGirdModel(int openCount = 0, int index = -1, PackType type = PackType.Deleted)
-        {
-            this.OpenCount = openCount;
-            this.packType = type;
-            this.Index = index;
-        }
-
-        #endregion
-
         #region 鑾峰彇浠撳簱鏁版嵁
-        public void SendOpenWarehouse()
+        public void RequestWarehouseData()
         {
             var openWarehouse = new CA204_tagCMOpenLongWarehouse();
             GameNetSystem.Instance.SendInfo(openWarehouse);
         }
+
         #endregion
     }
 }

--
Gitblit v1.8.0