Jelajahi Sumber

背包道具数据修改;
装备修改

zhenglijun 6 hari lalu
induk
melakukan
74f9f345cd

TEMPAT SAMPAH
Assets/Res/Addressable/FGUI/Equip/Equip_fui.bytes


+ 3 - 0
Assets/Scripts/Business/Domain/Network/model/act_equip_ls_m.cs

@@ -21,6 +21,9 @@ namespace FL.Network
         /// <summary> 装备属性 </summary>
         public System.Collections.Generic.List<EpsSchema> eps;
 
+        /// <summary> 这件装备战力不受其他模块影响 </summary>
+        public long power;
+
     }
 
 }

+ 3 - 0
Assets/Scripts/Business/Domain/Network/model/act_equip_m.cs

@@ -21,6 +21,9 @@ namespace FL.Network
         /// <summary> 装备属性 </summary>
         public System.Collections.Generic.List<EpsSchema> eps;
 
+        /// <summary> 这件装备战力不受其他模块影响 </summary>
+        public long power;
+
     }
 
 }

+ 66 - 115
Assets/Scripts/Business/Runtime/Data/EquipData.cs

@@ -2,7 +2,6 @@
 using FL.Network;
 using System;
 using System.Collections.Generic;
-using UnityEngine;
 using XGame.Database;
 using XGame.Framework.Data;
 
@@ -10,10 +9,9 @@ namespace FL
 {
     public class EquipData : DataSingleton<EquipData>, IDisposable
     {
-        private Dictionary<EEquipType, EquipItem> _wearEquipDic = new Dictionary<EEquipType, EquipItem>(); // 身上穿戴的装备数据
-        private List<EquipItem> _temporaryEquipList = new List<EquipItem>(); // 开宝藏箱子掉落的临时装备列表
-        private List<EquipItem> _bagEquipList = new List<EquipItem>(); // 装备背包列表
-        private List<EquipItem> _replaceEquipList = new List<EquipItem>();
+        private Dictionary<EEquipType, EquipItem> _wearEquipMap = new Dictionary<EEquipType, EquipItem>(); // 身上穿戴的装备数据
+        private Dictionary<long, EquipItem> _temporaryEquipMap = new Dictionary<long, EquipItem>();// 开宝藏箱子掉落的临时装备数据
+        private Dictionary<long, EquipItem> _bagEquipMap = new Dictionary<long, EquipItem>();// 装备背包中的装备数据
 
 
         /// <summary>
@@ -29,11 +27,7 @@ namespace FL
         /// <returns></returns>
         public EquipItem GetWearEquipData(EEquipType equipType)
         {
-            if (_wearEquipDic.ContainsKey(equipType))
-            {
-                return _wearEquipDic[equipType];
-            }
-            return null;
+            return _wearEquipMap.ContainsKey(equipType) ? _wearEquipMap[equipType] : null;
         }
 
         /// <summary>
@@ -43,7 +37,7 @@ namespace FL
         /// <param name="id"></param>
         public void AddWearEquip(EEquipType equipType, EquipItem equipData)
         {
-            _wearEquipDic.Add(equipType, equipData);
+            _wearEquipMap.Add(equipType, equipData);
         }
 
         /// <summary>
@@ -53,7 +47,7 @@ namespace FL
         /// <returns></returns>
         public bool IsWear(EEquipType equipType)
         {
-            return _wearEquipDic.ContainsKey(equipType);
+            return _wearEquipMap.ContainsKey(equipType);
         }
 
         /// <summary>
@@ -63,32 +57,38 @@ namespace FL
         /// <param name="id"></param>
         public void ChangeWearEquipData(EEquipType equipType, EquipItem data)
         {
-            if (_wearEquipDic.ContainsKey(equipType))
+            if (_wearEquipMap.ContainsKey(equipType))
+            {
+                _wearEquipMap[equipType] = data;
+            }
+            else
             {
-                _wearEquipDic[equipType] = data;
+                _wearEquipMap.Add(equipType, data);
             }
         }
 
+
+
         /// <summary>
         /// 清除身上穿戴的装备数据
         /// </summary>
         public void ClearWearEquip()
         {
-            foreach (EquipItem item in _wearEquipDic.Values)
+            foreach (EquipItem item in _wearEquipMap.Values)
             {
                 if (item != null)
                     item.Dispose();
             }
-            _wearEquipDic.Clear();
+            _wearEquipMap.Clear();
         }
 
         /// <summary>
-        /// 装备背包新增一个抓过南北数据
+        /// 装备背包新增一件装备
         /// </summary>
         /// <param name="equip"></param>
         public void AddEquip(EquipItem equip)
         {
-            _bagEquipList.Add(equip);
+            _bagEquipMap.Add(equip.Id, equip);
         }
 
         /// <summary>
@@ -99,7 +99,7 @@ namespace FL
 
         public EquipItem GetBagEquipItem(long uid)
         {
-            return _bagEquipList.Find(item => item.Id == uid);
+            return _bagEquipMap.ContainsKey(uid) ? _bagEquipMap[uid] : null;
         }
         /// <summary>
         /// 把更换下来的装备数据替换到装备背包中对应的
@@ -108,30 +108,12 @@ namespace FL
         /// <param name="replaceEquipData"></param>
         public void UpdataBagEquipData(EquipItem equipData)
         {
-            for (int i = 0; i < _bagEquipList.Count; i++)
-            {
-                if (_bagEquipList != null && _bagEquipList[i].Id == equipData.Id)
-                {
-                    _bagEquipList[i] = equipData;
-                    return;
-                }
-            }
+            if (_bagEquipMap.ContainsKey(equipData.Id))
+                _bagEquipMap[equipData.Id] = equipData;
+            else
+                _bagEquipMap.Add(equipData.Id, equipData);
         }
 
-        
-        public void ClearReplaceData() 
-        {
-            _replaceEquipList.Clear();
-        }
-
-        /// <summary>
-        /// 获取装备背包中的装备列表
-        /// </summary>
-        /// <param name="equipList"></param>
-        public void GetEquipList(ref List<EquipItem> equipList)
-        {
-            equipList.AddRange(_bagEquipList);
-        }
 
         /// <summary>
         /// 移除装备背包中的某件装备
@@ -140,18 +122,11 @@ namespace FL
         /// <param name="bDispose"></param>
         public void RemoveEquip(long id, bool bDispose = false)
         {
-            for (int i = 0; i < _bagEquipList.Count; i++)
+            if (bDispose)
             {
-                if (_bagEquipList[i].Id == id)
-                {
-                    if (bDispose)
-                    {
-                        _bagEquipList[i].Dispose();
-                    }
-                    _bagEquipList.RemoveAt(i);
-                    return;
-                }
+                _bagEquipMap[id]?.Dispose();
             }
+            _bagEquipMap.Remove(id);
         }
 
         /// <summary>
@@ -159,12 +134,11 @@ namespace FL
         /// </summary>
         public void ClearEquipBag()
         {
-            foreach (EquipItem item in _bagEquipList)
+            foreach (var item in _bagEquipMap)
             {
-                if (item != null)
-                    item.Dispose();
+                item.Value.Dispose();
             }
-            _bagEquipList.Clear();
+            _bagEquipMap.Clear();
         }
 
         /// <summary>
@@ -172,11 +146,9 @@ namespace FL
         /// </summary>
         /// <param name="equip"></param>
         /// <param name="bAddBag">是否添加到装备背包中</param>
-        public void AddTemporaryEquip(EquipItem equip,bool bAddBag = true)
+        public void AddTemporaryEquip(EquipItem equip)
         {
-            _temporaryEquipList.Add(equip);
-            if (bAddBag)
-                AddEquip(equip);
+            _temporaryEquipMap.Add(equip.Id, equip);
         }
 
         /// <summary>
@@ -186,7 +158,7 @@ namespace FL
         /// <returns></returns>
         public EquipItem GetTemporaryEquipItem(long uid)
         {
-            return _temporaryEquipList.Find(item => item.Id == uid);
+            return _temporaryEquipMap.ContainsKey(uid) ? _temporaryEquipMap[uid] : null;
         }
 
         /// <summary>
@@ -195,7 +167,7 @@ namespace FL
         /// <param name="equipList"></param>
         public void GetBagEquipList(ref List<EquipItem> equipList)
         {
-            equipList.AddRange(_bagEquipList);
+            equipList.AddRange(_bagEquipMap.Values);
         }
 
         /// <summary>
@@ -204,7 +176,7 @@ namespace FL
         /// <returns></returns>
         public bool IsEquipbagEmpty()
         {
-            return _bagEquipList?.Count == 0;
+            return _bagEquipMap.Count == 0;
         }
 
         /// <summary>
@@ -213,7 +185,7 @@ namespace FL
         /// <returns></returns>
         public bool IsWearEquipEmpty()
         {
-            return _wearEquipDic.Count == 0;
+            return _wearEquipMap.Count == 0;
         }
 
         /// <summary>
@@ -230,24 +202,31 @@ namespace FL
             if (equipData?.eps?.Count > 0)
             {
                 Attributes attr = _equipItem.Attributes;
-                if (attr != null)
-                {
-                    foreach (var item in equipData.eps)
-                    {
-                        attr.SetValue((EAttributeType)item.epid, item.val);
-                    }
-                }
+                GetEquipAttributes(equipData.eps, ref attr);
             }
 
             //装备的属性列表
             var equipAttributes = new List<EAttributeType>();
             _equipItem.Attributes.GetAll(ref equipAttributes, 0);
 
-            _equipItem.FightingPower = GetFightingPower(equipAttributes, _equipItem);
+            _equipItem.FightingPower = equipData.power;
             return _equipItem;
         }
 
         /// <summary>
+        /// 装备属性
+        /// </summary>
+        /// <param name="equipEps"></param>
+        /// <param name="attrs"></param>
+        public void GetEquipAttributes(List<EpsSchema> equipEps, ref Attributes attrs)
+        {
+            foreach (var item in equipEps)
+            {
+                attrs.SetValue((EAttributeType)item.epid, item.val);
+            }
+        }
+
+        /// <summary>
         /// 获取装备的数据信息
         /// </summary>
         /// <param name="equipData"></param>
@@ -261,61 +240,33 @@ namespace FL
             if (equipData?.eps?.Count > 0)
             {
                 Attributes attr = _equipItem.Attributes;
-                if (attr != null)
-                {
-                    foreach (var item in equipData.eps)
-                    {
-                        attr.SetValue((EAttributeType)item.epid, item.val);
-                    }
-                }
+                GetEquipAttributes(equipData.eps, ref attr);
             }
 
-            //装备的属性列表
-            var equipAttributes = new List<EAttributeType>();
-            _equipItem.Attributes.GetAll(ref equipAttributes, 0);
-
-            _equipItem.FightingPower = GetFightingPower(equipAttributes, _equipItem);
+            _equipItem.FightingPower = equipData.power;
             return _equipItem;
         }
+
         /// <summary>
-        /// 获取装备的属性转化的战斗力值
+        /// 身上穿戴的装备的战力值
         /// </summary>
-        /// <param name="attrMap"></param>
+        /// <param name="equipPart"></param>
         /// <returns></returns>
-        private long GetFightingPower(List<EAttributeType> attributeList, EquipItem equipItem)
+        public void GetWearEquipPower(ref Dictionary<EEquipType, long> wearEquipPowerMap)
         {
-            long fightPower = 0;
-            foreach (var item in attributeList)
+            foreach (var item in _wearEquipMap)
             {
-                fightPower += GetAttrToFightingPower(item, equipItem.Attributes.GetValue(item));
+                wearEquipPowerMap[item.Key] = item.Value.FightingPower;
             }
-            return fightPower;
-        }
-        /// <summary>
-        /// 属性类型转化为战力值
-        /// </summary>
-        /// <returns></returns>
-        private int GetAttrToFightingPower(EAttributeType attributeType, long attributeVal)
-        {
-            AttrDescTable attrInfo = AttrDescTableRepo.Get((int)attributeType);
-            Debug.Assert(attrInfo != null, $"AttrDescTable表不存在属性类型{attributeType}");
-            bool bRatio = attrInfo.Num_type == 1 || attributeType == EAttributeType.AtkSpeed;
-            return Mathf.CeilToInt(attrInfo.PowerConversion.ToReal() * (bRatio ? (float)attributeVal.ToRealDouble() : attributeVal));
         }
 
         /// <summary>
-        /// 获取装备属性的总战力
+        /// 获取身上部位的装备战力值
         /// </summary>
-        /// <param name="epsList"></param>
         /// <returns></returns>
-        public long GetEquipPower(List<EpsSchema> epsList)
+        public long GetWearPartPower(EEquipType equipPart)
         {
-            long fightPower = 0;
-            foreach (var item in epsList)
-            {
-                fightPower += GetAttrToFightingPower((EAttributeType)item.epid, item.val);
-            }
-            return fightPower;
+            return _wearEquipMap.ContainsKey(equipPart) ? _wearEquipMap[equipPart].FightingPower : 0;
         }
 
         /// <summary>
@@ -323,21 +274,21 @@ namespace FL
         /// </summary>
         public void ClearTemporaryEquipList()
         {
-            if (_temporaryEquipList?.Count > 0)
+            if (_temporaryEquipMap?.Count > 0)
             {
-                _temporaryEquipList.Clear();
+                _temporaryEquipMap.Clear();
             }
         }
 
         void IDisposable.Dispose()
         {
-            if (_wearEquipDic?.Count > 0)
+            if (_wearEquipMap.Count > 0)
             {
-                foreach (var item in _wearEquipDic.Values)
+                foreach (var item in _wearEquipMap.Values)
                 {
                     (item as IDisposable)?.Dispose();
                 }
-                _wearEquipDic.Clear();
+                _wearEquipMap.Clear();
             }
             ClearTemporaryEquipList();
             ClearEquipBag();

+ 13 - 88
Assets/Scripts/Business/Runtime/Data/Items/ItemData.cs

@@ -14,8 +14,6 @@ namespace FL.Data
         public long id;
         public int tableId;
         public long num;
-        public int girdIndex; // 背包格子索引
-        public EquipItem equipItemData;
     }
 
     public class ItemData : DataSingleton<ItemData>, IDisposable
@@ -27,103 +25,37 @@ namespace FL.Data
         /// </summary>
         /// <param name="tableId"></param>
         /// <param name="count"></param>
-        public void AddItemData(int tableId, long count, bool bAdd = false)
+        public void AddItemData(int tableId, long count)
         {
-            // 如果背包中已拥有该道具直接改变物品数量
-            if (OnChangeItemNum(tableId, count, bAdd))
+            if (_bagItemDataDic.ContainsKey(tableId))
             {
+                _bagItemDataDic[tableId].num += count;
+                if (_bagItemDataDic[tableId].num == 0)
+                {
+                    // 移除
+                    _bagItemDataDic.Remove(tableId);
+                }
                 return;
             }
-            int girdIndex = GetEmptyGridIndex();
-            AddBagItemData(girdIndex, new BagItemData()
+
+            _bagItemDataDic.Add(tableId, new BagItemData()
             {
-                id = UIDDefine.New(),
+                id = tableId,
                 tableId = tableId,
                 num = count,
-                girdIndex = girdIndex,
             });
         }
 
         /// <summary>
-        /// 模拟数据测试用
-        /// </summary>
-        /// <returns></returns>
-        public int GetEmptyGridIndex()
-        {
-            return _bagItemDataDic.Count + 1;
-        }
-        /// <summary>
-        /// 添加背包格子数据
-        /// </summary>
-        /// <param name="index"></param>
-        /// <param name="data"></param>
-        public void AddBagItemData(int index, BagItemData data)
-        {
-            _bagItemDataDic.Add(index, data);
-        }
-
-
-        /// <summary>
         /// 拥有的道具数量
         /// </summary>
         /// <param name="tableId"></param>
         /// <returns></returns>
         public long GetItemNum(int tableId)
         {
-            long count = 0;
-            foreach (var item in _bagItemDataDic)
-            {
-                if (item.Value?.tableId == tableId)
-                {
-                    count += item.Value.num;
-                }
-            }
-            return count;
-        }
-       
-        /// <summary>
-        /// 减少物品数量
-        /// </summary>
-        /// <param name="tableId"></param>
-        /// <param name="count"></param>
-        public void ReduceItemNum(int tableId, long count)
-        {
-            for (int i = 1; i <= _bagItemDataDic.Count; i++)
-            {
-                if (_bagItemDataDic[i]?.tableId == tableId)
-                {
-                    if (_bagItemDataDic[i].num > count)
-                    {
-                        _bagItemDataDic[i].num -= count;
-                        return;
-                    }
-                    else
-                    {
-                        count -= _bagItemDataDic[i].num;
-                        _bagItemDataDic[i] = null;
-                    }
-                }
-            }
+            return _bagItemDataDic.ContainsKey(tableId) ? _bagItemDataDic[tableId].num : 0;  
         }
-        /// <summary>
-        /// 道具数量变化
-        /// </summary>
-        /// <param name="tableId"></param>
-        /// <param name="count"></param>
-        /// <returns></returns>
-        public bool OnChangeItemNum(int tableId, long count, bool bAdd)
-        {
-            for (int i = 1; i <= _bagItemDataDic.Count; i++)
-            {
-                if (_bagItemDataDic[i]?.tableId == tableId)
-                {
-                    _bagItemDataDic[i].num = bAdd ? (_bagItemDataDic[i].num + count) : count;
-                    return true;   
-                }
-            }
-            return false;
-        }
-
+        
         /// <summary>
         /// 获取礼包|红包类型道具(道具页签),常规道具类型(材料页签)用来在背包界面显示
         /// </summary>
@@ -137,13 +69,6 @@ namespace FL.Data
         {
             if (_bagItemDataDic?.Count > 0) 
             {
-                foreach (var item in _bagItemDataDic)
-                {
-                    if (item.Value?.equipItemData != null)
-                    {
-                        item.Value.equipItemData.Dispose();
-                    }
-                }
                 _bagItemDataDic.Clear();
             }
         }

+ 1 - 1
Assets/Scripts/Business/Runtime/FGUI/Equip/AttrItemNested/EquipAttrItemNestedCtrl.cs

@@ -53,7 +53,7 @@ namespace FL.FGUI
 
             VM.AttrLabel.text = GetAttributeDesc(attributeInfo, attributeVal, attributeType == EAttributeType.AtkSpeed);
 
-            bool bSpecialAttr = attributeType.IsItemSpecial();
+            //bool bSpecialAttr = attributeType.IsItemSpecial();
             //VM.DescLabel.visible = bSpecialAttr;
             //if (bSpecialAttr)
             //{

+ 6 - 9
Assets/Scripts/Business/Runtime/FGUI/Equip/EquipItemNested/EquipEquipItemNestedCtrl.cs

@@ -105,7 +105,7 @@ namespace FL.FGUI
         {
             InitUI();
             //装备的属性列表
-            equipData.Attributes.GetAll(ref _allAttrTypeList, 0);
+            //equipData.Attributes.GetAll(ref _allAttrTypeList, 0);
             equipData.Attributes.GetAll(ref _specialAttrTypeList, 2);
             if (_specialAttrTypeList.Count > 0)
             {
@@ -118,11 +118,10 @@ namespace FL.FGUI
 
             foreach (var item in _basicAttrItemMap)
             {
-                bool bShowAttrItem = _allAttrTypeList.FindIndex(attrType => attrType == item.Key) != -1;
-                if (bShowAttrItem)
+                long attributeVal = equipData.Attributes.GetValue(item.Key);
+                if (attributeVal > 0)
                 {
-                    long attributeVal = equipData.Attributes.GetValue(item.Key);
-                    var compareType = bWear ? eCompareType.None : GetCompareType(item.Key, attributeVal, wearEquip);
+                    var compareType = GetCompareType(attributeVal, wearEquip == null ? 0 : wearEquip.Attributes.GetValue(item.Key));
                     item.Value.Ctrl.ShowUI(item.Key, attributeVal, compareType, true);
                 }
                 else
@@ -139,11 +138,9 @@ namespace FL.FGUI
         /// <param name="atrrVal"></param>
         /// <param name="wearEquip"></param>
         /// <returns></returns>
-        private eCompareType GetCompareType(EAttributeType attributeType, long atrrVal, EquipItem wearEquip)
+        private eCompareType GetCompareType(long atrrVal, long wearAttrVal)
         {
-            if (wearEquip == null) return eCompareType.None;
-            long val = wearEquip.Attributes.GetValue(attributeType);
-            return atrrVal == val ? eCompareType.None : (atrrVal > val ? eCompareType.Higth : eCompareType.Low);
+            return atrrVal == wearAttrVal ? eCompareType.None : (atrrVal > wearAttrVal ? eCompareType.Higth : eCompareType.Low);
         }
     }
 }

+ 0 - 1
Assets/Scripts/Business/Runtime/FGUI/Player/MainPanel/PlayerMainPanelCtrl.cs

@@ -235,7 +235,6 @@ namespace FL.FGUI
         /// <param name="args"></param>
         private void RefreshWearEquipUI(int eventId, object args)
         {
-            XGame.Log.Info("刷新身上穿戴的装备信息");
             ShowEquipUI();
         }
         #endregion

+ 69 - 17
Assets/Scripts/Business/Runtime/FGUI/TemporaryEquip/BagPanel/TemporaryEquipBagPanelCtrl.cs

@@ -21,17 +21,25 @@ namespace FL.FGUI
     public partial class TemporaryEquipBagPanelCtrl : UIController<TemporaryEquipBagPanelVM>
     {
         private const int MaxRow = 6;// 最大行数
+        private List<EquipItem> _equipDataList; //装备背包的数据
+        private Dictionary<EEquipType, long> _wearEquipPowerMap; // 身上部位穿戴的装备战力数据
 
         protected override void OnEnable(object intent)
         {
             AddUIListenres();
             EventSingle.Instance.AddListener(EventDefine.RefreshTemporaryEquip, RefreshTemporaryEquip);
+            EventSingle.Instance.AddListener(EventDefine.OnChangeEquip, OnChangeEquip);
             ShowUI();
         }
         protected override void OnDisable()
         {
             RemoveUIListenres();
             EventSingle.Instance.RemoveListener(EventDefine.RefreshTemporaryEquip, RefreshTemporaryEquip);
+            EventSingle.Instance.RemoveListener(EventDefine.OnChangeEquip, OnChangeEquip);
+            _wearEquipPowerMap?.Clear();
+            _wearEquipPowerMap = null;
+            _equipDataList?.Clear();
+            _equipDataList = null;
         }
         #region UI事件
         private void AddUIListenres()
@@ -54,28 +62,47 @@ namespace FL.FGUI
         }
 
         #endregion
+
+        private void Init()
+        {
+            if (_equipDataList == null) _equipDataList = new List<EquipItem>();
+            else _equipDataList.Clear();
+
+            if (_wearEquipPowerMap == null)
+            {
+                _wearEquipPowerMap = new Dictionary<EEquipType, long>();
+                for (int i = 1; i  < 7; i++)
+                {
+                    _wearEquipPowerMap.Add((EEquipType)i, 0);
+                }
+            }
+            EquipData.Instance.GetWearEquipPower(ref _wearEquipPowerMap);
+        }
+
         private void ShowUI()
         {
             bool bEmpty = EquipData.Instance.IsEquipbagEmpty();
             VM.EmptyCtrl.selectedIndex = bEmpty ? 1 : 0;
             if (bEmpty)
             {
+                VM.ListBG.height = 425;
+                VM.UIGroup.height = 462;
                 return;
             }
+            Init();
 
-            var equipDataList = new List<EquipItem>();
-            EquipData.Instance.GetBagEquipList(ref equipDataList);
-            OnSortEquipDataList(ref equipDataList);
-            VM.EquipList.BindDatas(equipDataList);
-            int num = (int)Math.Ceiling(equipDataList.Count / 5.0f);
+            EquipData.Instance.GetBagEquipList(ref _equipDataList);
+            OnSortEquipDataList();
+            VM.EquipList.BindDatas(_equipDataList);
+            int num = (int)Math.Ceiling(_equipDataList.Count / 5.0f);
             int addHeight = (Math.Min(num, MaxRow)-1) * 140 -32;
             VM.EquipList.height = 140 + addHeight;
             VM.ListBG.height = 425 + addHeight;
             VM.UIGroup.height = 462 + addHeight;
         }
-        private void OnSortEquipDataList(ref List<EquipItem> equipDataList)
+        private void OnSortEquipDataList()
         {
-            equipDataList.Sort((a, b) =>
+            _equipDataList.Sort((a, b) =>
             {
                 var aHighPower = GetCompareValue(a);
                 var bHighPower = GetCompareValue(b);
@@ -88,34 +115,59 @@ namespace FL.FGUI
                     return b.FightingPower.CompareTo(a.FightingPower); //降序
                 }
                 else
-                    return bHighPower.CompareTo(aHighPower);
+                    return bHighPower - aHighPower;
             });
         }
+
+        /// <summary>
+        /// 比身上穿戴的装备的战力高标识
+        /// </summary>
+        /// <param name="equipData"></param>
+        /// <returns></returns>
         private int GetCompareValue(EquipItem equipData)
         {
             int compareFlag = 0;
-            if (equipData?.Table?.Part > 0)
+            if (equipData?.Table.Part > 0)
             {
-                long compareFightingPower = equipData?.FightingPower ?? 0;
-                var equipItem = EquipData.Instance.GetWearEquipData(equipData.Table.Part);
-                long wearFightingPower = equipItem?.FightingPower ?? 0;
-                if (compareFightingPower > wearFightingPower)
+                if (equipData.FightingPower > _wearEquipPowerMap[equipData.Table.Part])
                     compareFlag = 1;
             }
             return compareFlag;
         }
 
         /// <summary>
+        /// 更换装备
+        /// </summary>
+        /// <param name="type"></param>
+        /// <param name="id"></param>
+        private void OnChangeEquip(int eventId, object args)
+        {
+            if (args == null)
+            {
+                return;
+            }
+            var changeEquipPartList = args as List<EEquipType>;
+            if (changeEquipPartList?.Count > 0)
+            {
+                foreach (var equipPart in changeEquipPartList)
+                {
+                    _wearEquipPowerMap[equipPart] = EquipData.Instance.GetWearPartPower(equipPart);
+                }
+            }
+        }
+
+        /// <summary>
         /// 刷新临时装备背包
         /// </summary>
         /// <param name="eventId"></param>
         /// <param name="args"></param>
         private void RefreshTemporaryEquip(int eventId, object args)
         {
-            var equipDataList = new List<EquipItem>();
-            EquipData.Instance.GetBagEquipList(ref equipDataList);
-            OnSortEquipDataList(ref equipDataList);
-            VM.EquipList.BindDatas(equipDataList);
+            _equipDataList.Clear();
+            EquipData.Instance.GetBagEquipList(ref _equipDataList);
+            OnSortEquipDataList();
+            VM.EquipList.BindDatas(_equipDataList);
+            VM.EquipList.scrollPane.SetPercY(0,false);
         }
     }
 }

+ 13 - 13
Assets/Scripts/Business/Runtime/Network/Controllers/ActEquipChuanPushCtrl.cs

@@ -11,6 +11,7 @@ namespace FL.Network
         {
             //XGame.Log.Info("接受到201301消息ActEquipChuanPushCtrl");
             if (message == null) return;
+            long uid = 0;
             List<EEquipType> changeEquipPartList = new List<EEquipType>();
             foreach (var item in message.chuan)
             {
@@ -18,24 +19,23 @@ namespace FL.Network
                 EquipItem wearEquip = EquipData.Instance.GetWearEquipData((EEquipType)item.buwei);
                 if (wearEquip == null)
                 {
-                    EquipData.Instance.AddWearEquip((EEquipType)item.buwei, EquipData.Instance.GetNewWearEquipData(item));
+                    wearEquip = new EquipItem();
                 }
-                else
-                {
-                    wearEquip.Init(EquipmentTableRepo.Get(item.equipId), wearEquip.Id);
-                    wearEquip.Level = item.level;
-                    wearEquip.FightingPower = EquipData.Instance.GetEquipPower(item.eps);
-                    wearEquip.Attributes.Clear();
-                    foreach (var attr in item.eps)
-                    {
-                        wearEquip.Attributes.SetValue((EAttributeType)attr.epid, attr.val);
-                    }
 
-                    EquipData.Instance.ChangeWearEquipData((EEquipType)item.buwei, wearEquip);
+                wearEquip.Init(EquipmentTableRepo.Get(item.equipId), wearEquip == null ? item.buwei : wearEquip.Id);
+                wearEquip.Level = item.level;
+                wearEquip.FightingPower = item.power;//EquipData.Instance.GetEquipPower(item.eps);
+                wearEquip.Attributes.Clear();
+                foreach (var attr in item.eps)
+                {
+                    wearEquip.Attributes.SetValue((EAttributeType)attr.epid, attr.val);
                 }
+
+                EquipData.Instance.ChangeWearEquipData((EEquipType)item.buwei, wearEquip);
+
                 changeEquipPartList.Add((EEquipType)item.buwei);
-                EventSingle.Instance.Notify(EventDefine.OnChangeEquip, changeEquipPartList);
             }
+            EventSingle.Instance.Notify(EventDefine.OnChangeEquip, changeEquipPartList);
         }
     }
 }

+ 18 - 10
Assets/Scripts/Business/Runtime/Network/Controllers/ActEquipLsListPushCtrl.cs

@@ -12,6 +12,7 @@ namespace FL.Network
             //XGame.Log.Info("消息201501 ActEquipLsListPushCtrl");
             if (message?.list?.Count > 0)
             {
+                bool bNew = false;
                 HashSet<long> changEquipIdList = new HashSet<long>();
                 foreach (var item in message.list)
                 {
@@ -20,20 +21,27 @@ namespace FL.Network
                     if (equipData == null)
                     {
                         // 非更换装备,新增掉落装备数据
-                        EquipData.Instance.AddTemporaryEquip(EquipData.Instance.GetDropEquipData(item));
+                        equipData = new EquipItem();
+                        bNew = true;
                     }
                     else
                     {
-                        equipData.Init(EquipmentTableRepo.Get(item.equipId), equipData.Id);
-                        equipData.Level = item.level;
-                        equipData.FightingPower = EquipData.Instance.GetEquipPower(item.eps);
-                        equipData.Attributes.Clear();
-                        foreach (var attr in item.eps)
-                        {
-                            equipData.Attributes.SetValue((EAttributeType)attr.epid, attr.val);
-                        }
-                        EquipData.Instance.UpdataBagEquipData(equipData);
+                        bNew = false;
                     }
+
+                    equipData.Init(EquipmentTableRepo.Get(item.equipId), item.xhid);
+                    equipData.Level = item.level;
+                    equipData.FightingPower = item.power;
+                    equipData.Attributes.Clear();
+                    foreach (var attr in item.eps)
+                    {
+                        equipData.Attributes.SetValue((EAttributeType)attr.epid, attr.val);
+                    }
+                    if (bNew)
+                    {
+                        EquipData.Instance.AddTemporaryEquip(equipData);
+                    }
+                    EquipData.Instance.UpdataBagEquipData(equipData);
                 }
                 if (changEquipIdList.Count > 0)
                     EventSingle.Instance.Notify(EventDefine.WearEquipSucess, changEquipIdList);

+ 1 - 6
Assets/Scripts/Business/Runtime/Network/Controllers/ActEquipLsPushCtrl.cs

@@ -1,9 +1,4 @@
-using FL.Data;
-using FL.Data.Items;
-using System.Collections.Generic;
-using UnityEngine;
-using XGame.Database;
-using XGame.Framework.Network;
+using XGame.Framework.Network;
 
 namespace FL.Network
 {

+ 1 - 1
Assets/Scripts/Business/Runtime/Network/Controllers/ActLongdanItemsPushCtrl.cs

@@ -17,7 +17,7 @@ namespace FL.Network
                         if (item?.count > 0)
                         {
                             // 非装备类型的道具物品
-                            ItemData.Instance.AddItemData(item.id, item.count, true);
+                            ItemData.Instance.AddItemData(item.id, item.count);
                         }
                     }
                 }

+ 1 - 4
Assets/Scripts/Business/Runtime/Network/Controllers/EquipIntoEquipResponseCtrl.cs

@@ -6,10 +6,7 @@ namespace FL.Network
     {
         protected override void OnProcess(EquipIntoEquipResponse message, object context)
         {
-            if (message?.code == 0) 
-            {
-                EventSingle.Instance.Notify(EventDefine.RefreshWearEquipUI);
-            }
+            EventSingle.Instance.Notify(EventDefine.RefreshWearEquipUI);
         }
     }
 }

+ 2 - 5
Assets/Scripts/Business/Runtime/Network/Controllers/LongdanOpenResponseCtrl.cs

@@ -6,11 +6,8 @@ namespace FL.Network
     {
         protected override void OnProcess(LongdanOpenResponse message, object context)
         {
-            if (message?.code == 0)
-            {
-                // 返回成功消息
-                EventSingle.Instance.Notify(EventDefine.OpenDragonTreasureSucess);
-            }
+            // 返回成功消息
+            EventSingle.Instance.Notify(EventDefine.OpenDragonTreasureSucess);
         }
     }
 }

+ 5 - 5
fl-fgui-project/assets/Equip/AttrItemNested.xml

@@ -1,23 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
 <component size="190,36" pivot="0.5,0.5">
-  <controller name="Compare" pages="0,,1,,2,,4," selected="1">
+  <controller name="Compare" pages="0,,1,,2,,4," selected="0">
     <remark page="0" value="不显示对比箭头"/>
     <remark page="1" value="红色向下箭头"/>
     <remark page="2" value="绿色向上箭头"/>
     <remark page="3" value="新属性"/>
   </controller>
-  <controller name="Show" pages="0,,1," selected="1">
+  <controller name="Show" pages="0,,1," selected="0">
     <remark page="0" value="隐藏"/>
     <remark page="1" value="显示"/>
   </controller>
   <displayList>
-    <text id="n0_fr8z" name="AttrLabel" xy="6,0" pivot="0,0.5" size="166,36" group="n5_u2a7" fontSize="26" vAlign="middle" leading="0" ubb="true" autoSize="none" autoClearText="true" text="生命属性 [color=#00FF00]123456789[/color]&#x9;"/>
-    <loader id="n1_fr8z" name="n1" xy="162,2" pivot="0.5,0.5" size="25,30" group="n5_u2a7" scale="0.8,0.8" url="ui://gt6q23qwbkez3o" align="center" vAlign="middle" fill="scaleFree">
+    <text id="n0_fr8z" name="AttrLabel" xy="4,0" pivot="0,0.5" size="175,36" group="n5_u2a7" fontSize="24" vAlign="middle" leading="0" ubb="true" autoSize="none" autoClearText="true" text="生命属性 [color=#00FF00]123456789[/color]&#x9;"/>
+    <loader id="n1_fr8z" name="n1" xy="139,-18" pivot="0.5,0.5" size="71,71" group="n5_u2a7" scale="0.8,0.8" align="center" vAlign="middle" fill="scaleFree">
       <gearDisplay controller="Compare" pages="1,2,4"/>
       <gearSize controller="Compare" pages="1,2,4" values="25,30,0.8,0.8|18,30,0.8,0.8|71,71,0.45,0.45" default="71,71,0.8,0.8"/>
       <gearIcon controller="Compare" pages="0,1,2,4" values="|ui://gt6q23qwbkez3o|ui://gt6q23qwbkez3p|ui://d1tqluu1e5nv4e"/>
     </loader>
-    <group id="n5_u2a7" name="n5" xy="6,0" size="181,36" advanced="true">
+    <group id="n5_u2a7" name="n5" xy="4,-18" size="206,71" advanced="true">
       <gearDisplay controller="Show" pages="1"/>
     </group>
   </displayList>