hch
2025-11-21 eb27e5fd31f73b998a4bbd85511a31e40b8c61b7
Main/System/KnapSack/Logic/ItemLogicUtility.cs
@@ -5,1782 +5,1391 @@
using UnityEngine;
    public class ItemLogicUtility : Singleton<ItemLogicUtility>
public class ItemLogicUtility : Singleton<ItemLogicUtility>
{
    // private string normalGSFormula;
    // private List<int> equipBaseProperties = new List<int>();
    // Dictionary<int, int> equipSkillScores = new Dictionary<int, int>();
    PackManager packModel { get { return PackManager.Instance; } }
    // BuffModel buffDatas { get { return ModelCenter.Instance.GetModel<BuffModel>(); } }
    // MountModel mountDatas { get { return ModelCenter.Instance.GetModel<MountModel>(); } }
    // PetModel petDatas { get { return ModelCenter.Instance.GetModel<PetModel>(); } }
    // StrengthenModel strengthDatas { get { return ModelCenter.Instance.GetModel<StrengthenModel>(); } }
    // MagicianModel magicianModel { get { return ModelCenter.Instance.GetModel<MagicianModel>(); } }
    // ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel<ComposeWinModel>(); } }
    // EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
    // AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
    public void Init()
    {
        private string dogzGSFormula;
        private string normalGSFormula;
        private Dictionary<int, string> specialSpiritPropertyFormula = new Dictionary<int, string>();
        Dictionary<int, int> specialSpiritPropertyMaxLevels;
        // var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
        // normalGSFormula = GSFormulaConfig.Numerical1;
        private int[] preciousItemTypes;
        private int[] preciousItemIDs; // 不展示的物品ID
        public int[] drugIDs;
        private int[] onekeySellTypes;
        private int[] pushItemIds;
        private int lsItemCnt; // 背包中的灵石数量
        private List<int> equipBaseProperties = new List<int>();
        private Dictionary<int, int> promptUseLimitDict;
        private Dictionary<int, List<int>> betterEquipExceptDungeonDict;
        Dictionary<int, int> equipSkillScores = new Dictionary<int, int>();
        PackManager packModel { get { return PackManager.Instance; } }
        // BuffModel buffDatas { get { return ModelCenter.Instance.GetModel<BuffModel>(); } }
        // MountModel mountDatas { get { return ModelCenter.Instance.GetModel<MountModel>(); } }
        // PetModel petDatas { get { return ModelCenter.Instance.GetModel<PetModel>(); } }
        // StrengthenModel strengthDatas { get { return ModelCenter.Instance.GetModel<StrengthenModel>(); } }
        // MagicianModel magicianModel { get { return ModelCenter.Instance.GetModel<MagicianModel>(); } }
        // ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel<ComposeWinModel>(); } }
        // EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        // AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
        public void Init()
        {
            var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
            dogzGSFormula = GSFormulaConfig.Numerical3;
            normalGSFormula = GSFormulaConfig.Numerical1;
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("OutOfPrintValue").Numerical2);
            foreach (var key in json.Keys)
            {
                specialSpiritPropertyFormula[int.Parse(key)] = json[key].ToString();
            }
            specialSpiritPropertyMaxLevels = ConfigParse.GetDic<int, int>(FuncConfigConfig.Get("OutOfPrintValueDes").Numerical1);
            var equipSkillScoreJson = JsonMapper.ToObject(GSFormulaConfig.Numerical4);
            foreach (var key in equipSkillScoreJson.Keys)
            {
                var skillId = 0;
                int.TryParse(key, out skillId);
                if (skillId != 0)
                {
                    equipSkillScores[skillId] = (int)equipSkillScoreJson[key];
                }
            }
            var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
            if (baseAttr.IsArray)
            {
                for (int i = 0; i < baseAttr.Count; i++)
                {
                    equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
                }
            }
            lsItemCnt = int.Parse(FuncConfigConfig.Get("LingshiShowCount").Numerical1);
            preciousItemTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("ItemPush").Numerical1);
            promptUseLimitDict = ConfigParse.GetDic<int, int>(FuncConfigConfig.Get("NoPromptUsetItem").Numerical1);
            preciousItemIDs = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("ItemPush").Numerical3);
            drugIDs = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("LifePotionlist").Numerical1);
            onekeySellTypes = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("OneKeySellItemType").Numerical1);
            pushItemIds = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("IntroductionItem").Numerical1);
            betterEquipExceptDungeonDict = new Dictionary<int, List<int>>();
            var excEquipData = JsonMapper.ToObject(FuncConfigConfig.Get("GoodItemDungeon").Numerical1);
            foreach (var dungeonId in excEquipData.Keys)
            {
                var itemIds = new List<int>();
                betterEquipExceptDungeonDict.Add(int.Parse(dungeonId), itemIds);
                for (var i = 0; i < excEquipData[dungeonId].Count; i++)
                {
                    var itemId = int.Parse(excEquipData[dungeonId][i].ToString());
                    itemIds.Add(itemId);
                }
            }
            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
        }
        void OnBeforePlayerDataInitialize()
        {
            isPackResetOk = true;
            ClearSortedBetterEquip();
        }
        #region 计算装备评分
        class EquipSorceProperties
        {
            Dictionary<int, int> properties = new Dictionary<int, int>();
            public int this[int id] { get { return properties[id]; } set { properties[id] = value; } }
            public List<int> Keys { get { return new List<int>(properties.Keys); } }
            void Add(int id, int value)
            {
                if (properties.ContainsKey(id))
                {
                    properties[id] += value;
                }
                else
                {
                    properties[id] = value;
                }
            }
            public void AddRange(List<int> ids, List<int> values)
            {
                if (ids == null || values == null)
                {
                    return;
                }
                var count = Mathf.Min(ids.Count, values.Count);
                for (int i = 0; i < count; i++)
                {
                    Add(ids[i], values[i]);
                }
            }
            public void AddRange(int[] ids, int[] values)
            {
                if (ids == null || values == null)
                {
                    return;
                }
                var length = Mathf.Min(ids.Length, values.Length);
                for (int i = 0; i < length; i++)
                {
                    Add(ids[i], values[i]);
                }
            }
            public void AddRange(Dictionary<int, int> keyValues)
            {
                if (keyValues == null)
                {
                    return;
                }
                foreach (var item in keyValues)
                {
                    Add(item.Key, item.Value);
                }
            }
            public void AddBaseProperties(int itemId, List<int> reference)
            {
                var config = ItemConfig.Get(itemId);
                if (config == null)
                {
                    return;
                }
                if (config.Effect1 != 0 && reference.Contains(config.Effect1))
                {
                    properties.Add(config.Effect1, config.EffectValueA1);
                }
                if (config.Effect2 != 0 && reference.Contains(config.Effect2))
                {
                    properties.Add(config.Effect2, config.EffectValueA2);
                }
                if (config.Effect3 != 0 && reference.Contains(config.Effect3))
                {
                    properties.Add(config.Effect3, config.EffectValueA3);
                }
                if (config.Effect4 != 0 && reference.Contains(config.Effect4))
                {
                    properties.Add(config.Effect4, config.EffectValueA4);
                }
                if (config.Effect5 != 0 && reference.Contains(config.Effect5))
                {
                    properties.Add(config.Effect5, config.EffectValueA5);
                }
            }
            public void AddCustomProperties(int itemId)
            {
                if (!AppointItemConfig.HasKey(itemId))
                {
                    return;
                }
                var config = AppointItemConfig.Get(itemId);
                AddRange(config.LegendAttrID, config.LegendAttrValue);
            }
            public bool ContainsKey(int id)
            {
                return properties.ContainsKey(id);
            }
        }
        public int GetEquipScore(int itemId, Dictionary<int, List<int>> useDataDic = null, bool isPreview = false)
        {
            var config = ItemConfig.Get(itemId);
            if (config == null) return 0;
            if (config.EquipPlace == 0)
            {
                return 0;
            }
            var properties = new EquipSorceProperties();
            if (IsCustomItem(itemId))
            {
                properties.AddBaseProperties(config.EffectValueA1, equipBaseProperties);
                properties.AddCustomProperties(itemId);
                return CalculateEquipScore(config.EffectValueA1, properties);
            }
            properties.AddBaseProperties(itemId, equipBaseProperties);
            if (useDataDic != null)
            {
                if (useDataDic.ContainsKey((int)ItemUseDataKey.legendAttrID))
                {
                    properties.AddRange(useDataDic[(int)ItemUseDataKey.legendAttrID], useDataDic[(int)ItemUseDataKey.legendAttrValue]);
                }
                if (useDataDic.ContainsKey((int)ItemUseDataKey.outOfPrintAttrID))
                {
                    properties.AddRange(useDataDic[(int)ItemUseDataKey.outOfPrintAttrID], useDataDic[(int)ItemUseDataKey.outOfPrintAttrValue]);
                }
            }
            return CalculateEquipScore(itemId, properties, useDataDic);
        }
        // private Dictionary<int, int> GetEquipLegendProperties(int itemId)
        // var equipSkillScoreJson = JsonMapper.ToObject(GSFormulaConfig.Numerical4);
        // foreach (var key in equipSkillScoreJson.Keys)
        // {
        //     var legendProperties = LegendPropertyUtility.GetLegendProFromEquipShen(itemId);
        //     if (legendProperties == null)
        //         legendProperties = LegendPropertyUtility.GetEquipProperties(itemId);
        //     var properties = new Dictionary<int, int>();
        //     if (legendProperties != null)
        //     var skillId = 0;
        //     int.TryParse(key, out skillId);
        //     if (skillId != 0)
        //     {
        //         foreach (var item in legendProperties)
        //         {
        //             properties[item.x] = item.y;
        //         }
        //         equipSkillScores[skillId] = (int)equipSkillScoreJson[key];
        //     }
        //     return properties;
        // }
        // private Dictionary<int, int> GetEquipShenProperties(int itemId)
        // var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
        // if (baseAttr.IsArray)
        // {
        //     var shenProperties = ShenPropertyUtility.GetEquipShenProperties(itemId);
        //     var properties = new Dictionary<int, int>();
        //     if (shenProperties != null)
        //     for (int i = 0; i < baseAttr.Count; i++)
        //     {
        //         foreach (var item in shenProperties)
        //         {
        //             properties[item.x] = item.y;
        //         }
        //         equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
        //     }
        //     return properties;
        // }
        public bool IsCustomItem(int itemId)
        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
    }
    void OnBeforePlayerDataInitialize()
    {
        isPackResetOk = true;
    }
    #region 计算装备评分
    class EquipSorceProperties
    {
        Dictionary<int, int> properties = new Dictionary<int, int>();
        public int this[int id] { get { return properties[id]; } set { properties[id] = value; } }
        public List<int> Keys { get { return new List<int>(properties.Keys); } }
        void Add(int id, int value)
        {
            if (!ItemConfig.HasKey(itemId))
            if (properties.ContainsKey(id))
            {
                return false;
            }
            return ItemConfig.Get(itemId).Effect1 == 220;
        }
        /// <summary>
        /// 得到装备的评分
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        private Dictionary<PropertyType, float> curEquipAttrDict = new Dictionary<PropertyType, float>(); //存储当前装备属性对应的数值 key 属性 value 属性值
        private int CalculateEquipScore(int itemId, EquipSorceProperties properties, Dictionary<int, List<int>> useDataDic = null)
        {
            var config = ItemConfig.Get(itemId);
            if (config == null || !GeneralDefine.CompareEquipPlaces.Contains(config.EquipPlace))
            {
                return 0;
            }
            //properties.AddRange(GetEquipShenProperties(itemId));
            var minAttack = properties.ContainsKey((int)PropertyType.MinAtk) ? properties[(int)PropertyType.MinAtk] : 0;
            var maxAttack = properties.ContainsKey((int)PropertyType.MaxAtk) ? properties[(int)PropertyType.MaxAtk] : 0;
            var attack = properties.ContainsKey((int)PropertyType.ATK) ? properties[(int)PropertyType.ATK] : 0;
            properties[(int)PropertyType.MinAtk] = minAttack + attack;
            properties[(int)PropertyType.MaxAtk] = maxAttack + attack;
            Equation.Instance.Clear();
            curEquipAttrDict.Clear();
            var GSProValueDict = EquipGSParamConfig.GetTagGsProValueDict(config.LV, config.ItemColor, config.SuiteiD > 0 ? 1 : 0, config.StarLevel);
            foreach (var key in properties.Keys)
            {
                var attrType = (PropertyType)key;
                switch (attrType)
                {
                    case PropertyType.ATKSPEED:
                    case PropertyType.OnlyFinalHurt:
                    case PropertyType.PVPAtkBackHP:
                    case PropertyType.MinAtk:
                    case PropertyType.MaxAtk:
                    case PropertyType.AddFinalHurt:
                    case PropertyType.ReduceFinalHurt:
                        curEquipAttrDict.Add(attrType, properties[key]);
                        break;
                    default:
                        if (GSProValueDict != null && GSProValueDict.ContainsKey(attrType))
                        {
                            var curProValue = properties[key] * GSProValueDict[attrType];
                            curEquipAttrDict.Add(attrType, curProValue);
                        }
                        else
                        {
                            curEquipAttrDict.Add(attrType, properties[key]);
                        }
                        break;
                }
            }
            foreach (var key in curEquipAttrDict.Keys)
            {
                var propertyConfig = PlayerPropertyConfig.Get((int)key);
                if (propertyConfig != null)
                {
                    Equation.Instance.AddKeyValue(propertyConfig.Parameter, curEquipAttrDict[key]);
                }
            }
            var skillScore = 0;
            if (useDataDic != null && useDataDic.ContainsKey((int)ItemUseDataKey.equipSkills))
            {
                for (int i = 0; i < useDataDic[(int)ItemUseDataKey.equipSkills].Count; i++)
                {
                    skillScore += equipSkillScores[useDataDic[(int)ItemUseDataKey.equipSkills][i]];
                }
                properties[id] += value;
            }
            else
            {
                if (config.AddSkill1 != 0 && equipSkillScores.ContainsKey(config.AddSkill1))
                {
                    skillScore += equipSkillScores[config.AddSkill1];
                }
                if (config.AddSkill2 != 0 && equipSkillScores.ContainsKey(config.AddSkill2))
                {
                    skillScore += equipSkillScores[config.AddSkill2];
                }
            }
            return skillScore + Equation.Instance.Eval<int>(normalGSFormula);
        }
        #endregion
        #region 主界面物品弹框展示
        public event Action<PackType, string> GetPreciousItemEvent; //得到珍品  value 物品的实例ID
        public event Action<PackType, string> GetExpItemEvent; //得到经验物品  value 物品的实例ID
        public void RecommendItem(ItemModel item)
        {
            if (item.packType != PackType.Item)
            {
                return;
            }
            if (!preciousItemTypes.Contains(item.config.Type))
            {
                int mapId = PlayerDatas.Instance.baseData.MapID;
                var drugList = packModel.GetDrugIDListByDungeonID(mapId);
                if (drugList == null)
                    return;
                if (!drugList.Contains(item.config.ID))
                    return;
            }
            if (item.config.Type == 145 && item.config.CDTime > 0)
            {
                var createTime = item.GetUseDataFirstValue((int)ItemUseDataKey.createTime);
                if (createTime > 0)
                {
                    DateTime useTime;
                    if (item.config.CDTypeEx == 1)
                    {
                        //itemConfig.CDTime 为天,过0点可用
                        useTime = TimeUtility.GetTime((uint)createTime).AddDays(item.config.CDTime);
                        useTime = TimeUtility.GetDayStartTime(useTime.Year, useTime.Month, useTime.Day);
                    }
                    else
                    {
                        useTime = TimeUtility.GetTime((uint)createTime).AddSeconds(item.config.CDTime);
                    }
                    if (TimeUtility.ServerNow < useTime)
                    {
                        return;
                    }
                }
            }
            if (preciousItemIDs != null && preciousItemIDs.Contains(item.config.ID))
            {
                return;
            }
            if (item.config.ID == packModel.lsItemID)
            {
                int tmpCnt = PlayerDatas.Instance.baseData.LV < 50 ? 5 : lsItemCnt;
                if (packModel.GetItemCountByID(PackType.Item, packModel.lsItemID) < tmpCnt)
                    return;
            }
            //if (item.isAuction)
            //{
            //    return;
            //}
            if (item.config.UseLV > PlayerDatas.Instance.baseData.LV)
            {
                return;
            }
            if (IsOverdue(item.guid))
            {
                return;
            }
            // if (!IsAbleToUse(item))
            // {
            //     return;
            // }
            if (IsSpiritWeapon(item.itemId))
            {
                if (IsFightUp(item.itemId, item.score) != 1)
                {
                    return;
                }
            }
            if (item.config.Type == 13)
            {
                // 经验丹特殊处理,优先显示
                if (GetExpItemEvent != null)
                {
                    GetExpItemEvent(item.packType, item.guid);
                }
            }
            else
            {
                if (GetPreciousItemEvent != null)
                {
                    GetPreciousItemEvent(item.packType, item.guid);
                }
                properties[id] = value;
            }
        }
        // bool IsAbleToUse(ItemModel item)
        // {
        //     var windowSearch = WindowSearchConfig.Get(item.config.Jump);
        //     if (windowSearch != null)
        //     {
        //         if (!FuncOpen.Instance.IsFuncOpen(windowSearch.Lv) && windowSearch.Lv != 0)
        //         {
        //             return false;
        //         }
        //     }
        //     if (pushItemIds.Contains(item.itemId))
        //     {
        //         var itemCnt = packModel.GetItemCountByID(PackType.Item, item.itemId) - item.count;
        //         if (itemCnt > 0)
        //         {
        //             return false;
        //         }
        //         else
        //         {
        //             if (item.preItemCount > 0)
        //             {
        //                 return false;
        //             }
        //         }
        //     }
        //     if (promptUseLimitDict.ContainsKey(item.itemId))
        //     {
        //         var playerLv = PlayerDatas.Instance.baseData.LV;
        //         if (playerLv < promptUseLimitDict[item.itemId])
        //         {
        //             return false;
        //         }
        //     }
        //     ulong canUseCnt = 0;
        //     if (packModel.IsReachUseLimit(item.guid, out canUseCnt))
        //     {
        //         return false;
        //     }
        //     bool isBox = false;
        //     bool isCanOpen = ModelCenter.Instance.GetModel<BoxGetItemModel>().CheckOpenBoxCondition(item.itemId, out isBox);
        //     if (isBox)
        //     {
        //         if (!isCanOpen)
        //         {
        //             return false;
        //         }
        //     }
        //     //if (trialModel.trialTokens.Contains(item.itemId))
        //     //{
        //     //    if (!trialModel.IsAnySatisfyExchangeBetter(item.itemId))
        //     //    {
        //     //        return false;
        //     //    }
        //     //}
        //     if (packModel.CheckIsDrugById(item.itemId))
        //     {
        //         if (item.config.RealmLimit > PlayerDatas.Instance.baseData.realmLevel)
        //         {
        //             return false;
        //         }
        //     }
        //     var fruitConfig = AttrFruitConfig.Get(item.itemId);
        //     if (fruitConfig != null && fruitConfig.FuncID == 2)
        //     {
        //         if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace))
        //         {
        //             return false;
        //         }
        //     }
        //     switch (item.config.Type)
        //     {
        //         case 8:
        //             if (buffDatas.BastBuff(item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 20:
        //             if (magicianModel.IsGodWeaponMaxLevelByItem(item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 21:
        //             if (!mountDatas.IsHint(HorseEnum.HorseDan, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 22:
        //             if (!mountDatas.IsHint(HorseEnum.HorseStone, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 41:
        //             if (!mountDatas.IsHint(HorseEnum.HorseDebris, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 26:
        //             if (!petDatas.IsHint(PetEnum.PetDebris, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 27:
        //             if (!petDatas.IsHint(PetEnum.PetDan, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 28:
        //             if (!petDatas.IsHint(PetEnum.PetStone, item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 25:
        //             if (!ModelCenter.Instance.GetModel<EquipGemModel>().IsBetterGem(item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 39:
        //             if (!IsBetterWings(item))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 52:
        //             if (!strengthDatas.IsHint(item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 55:
        //             if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace))
        //             {
        //                 return false;
        //             }
        //             var alchemyId = 0;
        //             if (alchemyModel.TryGetAlchemyByStudyMaterial(item.itemId, out alchemyId))
        //             {
        //                 var alchemyConfig = AlchemyConfig.Get(alchemyId);
        //                 int alchemingId;
        //                 if (alchemyModel.IsStoveAlcheming((AlchemyType)alchemyConfig.AlchemType, out alchemingId))
        //                 {
        //                     return false;
        //                 }
        //                 if (alchemyModel.IsGraspRecipe(alchemyId))
        //                 {
        //                     return false;
        //                 }
        //                 var studyError = 0;
        //                 if (!alchemyModel.TryLearn(alchemyId, out studyError))
        //                 {
        //                     return false;
        //                 }
        //             }
        //             break;
        //         case 127:
        //             var error = 0;
        //             bool isHaveMakeNum = ItemOperateUtility.Instance.CanUseItem(item.guid, 1, out error);
        //             int remainNum = CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum();
        //             if (!CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch
        //                 || remainNum > 0
        //                 || !isHaveMakeNum)
        //             {
        //                 return false;
        //             }
        //             break;
        //         default:
        //             break;
        //     }
        //     switch (item.itemId)
        //     {
        //         case 951:
        //             if (!CheckIsExtendGrid(item.itemId))
        //             {
        //                 return false;
        //             }
        //             break;
        //         case 952:
        //             return false;
        //             break;
        //     }
        //     return true;
        // }
        // private bool IsBetterWings(ItemModel item)
        // {
        //     if (item == null)
        //     {
        //         return false;
        //     }
        //     var putModel = packModel.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
        //     var singlePack = packModel.GetSinglePack(PackType.Item);
        //     if (singlePack == null)
        //     {
        //         return false;
        //     }
        //     int[] composeTypes = item.config.JumpComposeCondi;
        //     bool isOpenCompose = false;
        //     if (composeTypes != null && composeTypes.Length >= 3)
        //     {
        //         int first = composeTypes[0];
        //         int second = composeTypes[1];
        //         int third = composeTypes[2];
        //         ComposeWinModel.ComposeThirdTypeData thirdTypeData = null;
        //         composeModel.TryGetThirdTypeData(first, second, third, out thirdTypeData);
        //         if (thirdTypeData != null)
        //         {
        //             var itemCompound = thirdTypeData.itemCompound;
        //             if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
        //             {
        //                 isOpenCompose = true;
        //             }
        //         }
        //     }
        //     if (!isOpenCompose)
        //     {
        //         return false;
        //     }
        //     if (putModel != null && putModel.config.LV >= item.config.LV)
        //     {
        //         return false;
        //     }
        //     var itemModels = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
        //     {
        //         itemTypes = new List<int>() { (int)ItemType.Equip_Wing }
        //     });
        //     if (itemModels != null)
        //     {
        //         for (int i = 0; i < itemModels.Count; i++)
        //         {
        //             if (IsJobCompatibleItem(itemModels[i].itemId))
        //             {
        //                 if (itemModels[i].config.LV >= item.config.LV)
        //                 {
        //                     return false;
        //                 }
        //             }
        //         }
        //     }
        //     return true;
        // }
        private bool CheckIsExtendGrid(int itemId)
        public void AddRange(List<int> ids, List<int> values)
        {
            SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
            if (singlePack == null) return false;
            if (ids == null || values == null)
            {
                return;
            }
            int startLockIndex = singlePack.unlockedGridCount - GeneralDefine.initBagGridCount;
            FuncConfigConfig _tagFuncModel = FuncConfigConfig.Get("OpenBagItem");
            int haveCount = packModel.GetItemCountByID(PackType.Item, itemId);
            Equation.Instance.Clear();
            Equation.Instance.AddKeyValue("index", startLockIndex + 1);
            int needTool = Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
            if (haveCount >= needTool)
            var count = Mathf.Min(ids.Count, values.Count);
            for (int i = 0; i < count; i++)
            {
                Add(ids[i], values[i]);
            }
        }
        public void AddRange(int[] ids, int[] values)
        {
            if (ids == null || values == null)
            {
                return;
            }
            var length = Mathf.Min(ids.Length, values.Length);
            for (int i = 0; i < length; i++)
            {
                Add(ids[i], values[i]);
            }
        }
        public void AddRange(Dictionary<int, int> keyValues)
        {
            if (keyValues == null)
            {
                return;
            }
            foreach (var item in keyValues)
            {
                Add(item.Key, item.Value);
            }
        }
        public void AddBaseProperties(int itemId, List<int> reference)
        {
            var config = ItemConfig.Get(itemId);
            if (config == null)
            {
                return;
            }
            if (config.Effect1 != 0 && reference.Contains(config.Effect1))
            {
                properties.Add(config.Effect1, config.EffectValueA1);
            }
            if (config.Effect2 != 0 && reference.Contains(config.Effect2))
            {
                properties.Add(config.Effect2, config.EffectValueA2);
            }
            if (config.Effect3 != 0 && reference.Contains(config.Effect3))
            {
                properties.Add(config.Effect3, config.EffectValueA3);
            }
            if (config.Effect4 != 0 && reference.Contains(config.Effect4))
            {
                properties.Add(config.Effect4, config.EffectValueA4);
            }
            if (config.Effect5 != 0 && reference.Contains(config.Effect5))
            {
                properties.Add(config.Effect5, config.EffectValueA5);
            }
        }
        public void AddCustomProperties(int itemId)
        {
            if (!AppointItemConfig.HasKey(itemId))
            {
                return;
            }
            var config = AppointItemConfig.Get(itemId);
            AddRange(config.LegendAttrID, config.LegendAttrValue);
        }
        public bool ContainsKey(int id)
        {
            return properties.ContainsKey(id);
        }
    }
    // private Dictionary<int, int> GetEquipLegendProperties(int itemId)
    // {
    //     var legendProperties = LegendPropertyUtility.GetLegendProFromEquipShen(itemId);
    //     if (legendProperties == null)
    //         legendProperties = LegendPropertyUtility.GetEquipProperties(itemId);
    //     var properties = new Dictionary<int, int>();
    //     if (legendProperties != null)
    //     {
    //         foreach (var item in legendProperties)
    //         {
    //             properties[item.x] = item.y;
    //         }
    //     }
    //     return properties;
    // }
    // private Dictionary<int, int> GetEquipShenProperties(int itemId)
    // {
    //     var shenProperties = ShenPropertyUtility.GetEquipShenProperties(itemId);
    //     var properties = new Dictionary<int, int>();
    //     if (shenProperties != null)
    //     {
    //         foreach (var item in shenProperties)
    //         {
    //             properties[item.x] = item.y;
    //         }
    //     }
    //     return properties;
    // }
    public bool IsCustomItem(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        return ItemConfig.Get(itemId).Effect1 == 220;
    }
    /// <summary>
    /// 得到装备的评分
    /// </summary>
    /// <param name="itemId"></param>
    /// <returns></returns>
    private Dictionary<PropertyType, float> curEquipAttrDict = new Dictionary<PropertyType, float>(); //存储当前装备属性对应的数值 key 属性 value 属性值
    private void CalculateEquipAttr(int itemId, EquipSorceProperties properties)
    {
        var config = ItemConfig.Get(itemId);
        var minAttack = properties.ContainsKey((int)PropertyType.MinAtk) ? properties[(int)PropertyType.MinAtk] : 0;
        var maxAttack = properties.ContainsKey((int)PropertyType.MaxAtk) ? properties[(int)PropertyType.MaxAtk] : 0;
        var attack = properties.ContainsKey((int)PropertyType.ATK) ? properties[(int)PropertyType.ATK] : 0;
        properties[(int)PropertyType.MinAtk] = minAttack + attack;
        properties[(int)PropertyType.MaxAtk] = maxAttack + attack;
        curEquipAttrDict.Clear();
        foreach (var key in properties.Keys)
        {
            var attrType = (PropertyType)key;
            switch (attrType)
            {
                case PropertyType.ATKSPEED:
                case PropertyType.OnlyFinalHurt:
                case PropertyType.PVPAtkBackHP:
                case PropertyType.MinAtk:
                case PropertyType.MaxAtk:
                case PropertyType.AddFinalHurt:
                case PropertyType.ReduceFinalHurt:
                    curEquipAttrDict.Add(attrType, properties[key]);
                    break;
                default:
                    curEquipAttrDict.Add(attrType, properties[key]);
                    break;
            }
        }
    }
    #endregion
    /// <summary>
    /// <param name="packType 背包类型"></param>
    /// <param name="itemId 物品ID"></param>
    /// <param name="needCount 需要数量"></param>
    /// <param name="needTips">0 不响应 1 弹提示 2 弹获取途径tips</param>
    /// <returns></returns>
    public static bool CheckItemCount(PackType packType, int itemId, long needCount, int needTips = 0)
    {
        if (needCount <= 0)
        {
            return true;
        }
        var haveCount = PackManager.Instance.GetItemCountByID(packType, itemId);
        bool isEnough = haveCount >= needCount;
        if (!isEnough)
        {
            if (needTips == 1)
            {
                SysNotifyMgr.Instance.ShowTip("ItemNotEnough", itemId);
            }
            else if (needTips == 2)
            {
                ItemTipUtility.Show(itemId, true);
            }
        }
        return isEnough;
    }
    public event Action<string> GetBetterEquipEvent; //得到更好的装备 value 物品的实例ID
    // public void OnGetEquip(ItemModel item)
    // {
    //     if (item == null)
    //     {
    //         return;
    //     }
    //     if (item.packType != PackType.Item)
    //     {
    //         return;
    //     }
    //     if (!IsJobCompatibleItem(item.itemId))
    //     {
    //         return;
    //     }
    //     int equipPlace = item.config.EquipPlace;
    //     if ((RoleEquipType)equipPlace == RoleEquipType.Wing)
    //     {
    //         var wing = packModel.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
    //         if (wing == null)
    //         {
    //             if (!SpiritWeaponModel.hasAutoEquipWing)
    //             {
    //                 SpiritWeaponModel.hasAutoEquipWing = true;
    //                 ItemOperateUtility.Instance.PutOnItem(item.guid);
    //                 return;
    //             }
    //         }
    //     }
    //     switch ((RoleEquipType)equipPlace)
    //     {
    //         case RoleEquipType.Weapon:
    //         case RoleEquipType.Weapon2:
    //         case RoleEquipType.Hat:
    //         case RoleEquipType.Clothes:
    //         case RoleEquipType.Belt:
    //         case RoleEquipType.Trousers:
    //         case RoleEquipType.Shoes:
    //         case RoleEquipType.Neck:
    //         case RoleEquipType.FairyCan1:
    //         case RoleEquipType.FairyCan2:
    //         case RoleEquipType.Glove:
    //         case RoleEquipType.Jade:
    //         case RoleEquipType.Wing:
    //         case RoleEquipType.Guard:
    //         case RoleEquipType.PeerlessWeapon1:
    //         case RoleEquipType.PeerlessWeapon2:
    //             if (betterEquipExceptDungeonDict.ContainsKey(PlayerDatas.Instance.baseData.MapID))
    //             {
    //                 if (betterEquipExceptDungeonDict[PlayerDatas.Instance.baseData.MapID].Contains(item.itemId))
    //                 {
    //                     return;
    //                 }
    //             }
    //             SetGetBetterEquipEvent(item);
    //             break;
    //     }
    // }
    private void SetGetBetterEquipEvent(ItemModel model)
    {
        // // if (model.isAuction)
        // // {
        // //    return;
        // // }
        // var itemEffectTime = model.GetUseData((int)ItemUseDataKey.createTime);
        // if (!itemEffectTime.IsNullOrEmpty() && itemEffectTime.Count > 0)
        // {
        //     if (itemEffectTime[0] != 0)
        //     {
        //         var cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(model.guid);
        //         double remainTime = 0;
        //         if (cool != null)
        //         {
        //             remainTime = cool.GetRemainTime();
        //         }
        //         if (remainTime >= 0 && remainTime < 120 && model.config.ExpireTime > 0)
        //         {
        //             return;
        //         }
        //     }
        // }
        // if (!equipModel.IsLevelUnLocked(model.config.LV))
        // {
        //     return;
        // }
        // int isFightUp = IsFightUp(model.itemId, model.score);
        // if (isFightUp != 1)
        // {
        //     return;
        // }
        // if (GetBetterEquipEvent != null)
        // {
        //     GetBetterEquipEvent(model.guid);
        // }
    }
    Dictionary<int, ItemModel> RealmBetterDict = new Dictionary<int, ItemModel>();
    // public Dictionary<int, ItemModel> CheckBetterEquipByRealm()
    // {
    //     RealmBetterDict.Clear();
    //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
    //     if (singlePack == null) return RealmBetterDict;
    //     int realmLv = PlayerDatas.Instance.baseData.realmLevel;
    //     Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
    //     foreach (var model in pairs.Values)
    //     {
    //         var equipServerIndex = EquipSet.ClientPlaceToServerPlace(new Int2(model.config.LV, model.config.EquipPlace));
    //         if (model.config.EquipPlace > 0
    //             && model.config.EquipPlace != (int)RoleEquipType.Guard
    //             && model.config.RealmLimit <= realmLv
    //             && !IsOverdue(model.guid)
    //             && IsFightUp(model.itemId, model.score) == 1)
    //         {
    //             if (!RealmBetterDict.ContainsKey(equipServerIndex))
    //             {
    //                 RealmBetterDict.Add(equipServerIndex, model);
    //             }
    //             else
    //             {
    //                 if (model.score > RealmBetterDict[equipServerIndex].score)
    //                 {
    //                     RealmBetterDict[equipServerIndex] = model;
    //                 }
    //             }
    //         }
    //     }
    //     return RealmBetterDict;
    // }
    // List<ItemModel> RealmDruglist = new List<ItemModel>();
    // public List<ItemModel> GetDruglistByRealm()
    // {
    //     RealmDruglist.Clear();
    //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
    //     if (singlePack == null) return RealmDruglist;
    //     int realmLv = PlayerDatas.Instance.baseData.realmLevel;
    //     Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
    //     foreach (var model in pairs.Values)
    //     {
    //         if (packModel.CheckIsDrugById(model.itemId))
    //         {
    //             AttrFruitConfig fruitConfig = AttrFruitConfig.Get(model.itemId);
    //             if (!packModel.IsReachMaxUseDrug(fruitConfig)
    //                 && model.config.RealmLimit <= realmLv)
    //             {
    //                 RealmDruglist.Add(model);
    //             }
    //         }
    //     }
    //     return RealmDruglist;
    // }
    #region 物品处于CD中的逻辑处理
    private List<string> itemEffectTimelist = new List<string>(); //key 物品实例ID
    /// <summary>
    /// 物品使用时间限制
    /// </summary>
    public void SetItemEffectCDTime(string guid, int itemID, int getTime, int serverSurplusTime)
    {
        double time = GetTimeOffest(TimeUtility.GetTime((uint)getTime));
        if (time < 0)
        {
            time = 0;
        }
        ItemConfig itemConfig = ItemConfig.Get(itemID);
        if (time >= itemConfig.ExpireTime)
        {
            KnapsackTimeCDMgr.Instance.UnRegister(guid);
            return;
        }
        double remainTime = (serverSurplusTime > 0 ? serverSurplusTime : itemConfig.ExpireTime) - time;
        KnapsackTimeCDMgr.Instance.Register(guid, itemID, remainTime);
    }
    public double GetTimeOffest(DateTime getTime)
    {
        Debug.Log("现在时间:" + TimeUtility.ServerNow + "获得时间:" + getTime);
        //TimeUtility.SyncServerTime();
        TimeSpan t = TimeUtility.ServerNow - getTime;
        Debug.Log("时间差:" + t.TotalSeconds);
        return t.TotalSeconds;
    }
    #endregion
    #region 设置可以一键出售的物品数据
    private int playerLv;
    private Dictionary<int, List<ItemModel>> _lifePotionDict = new Dictionary<int, List<ItemModel>>(); //key 药水等级
    private List<int> _sellItemScorelist = new List<int>();
    private Dictionary<int, Dictionary<int, List<ItemModel>>> _sameIndexEquipDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>();  //存储相同装备位的装备
                                                                                                                                              // private  _sameEquipScoreDict = new Dictionary<int, List<ItemModel>>(); //存储相同ID中相同装备评分的装备
    private Dictionary<int, ItemModel> _packModelDict;
    private List<ItemModel> _sellItemlist = new List<ItemModel>();
    // public List<ItemModel> GetSellItemList()
    // {
    //     GetOneKeySellModel();
    //     _sellItemlist.Sort(SetSellItemOrder);
    //     return _sellItemlist;
    // }
    // public int SetSellItemOrder(ItemModel startModel, ItemModel endModel)
    // {
    //     bool startIsEquip = IsRealmEquip(startModel.itemId);
    //     bool endIsEquip = IsRealmEquip(endModel.itemId);
    //     if (startIsEquip.CompareTo(endIsEquip) != 0) return -startIsEquip.CompareTo(endIsEquip);
    //     int order1 = startModel.config.Type;
    //     int order2 = endModel.config.Type;
    //     if (order1.CompareTo(order2) != 0) return order1.CompareTo(order2);
    //     int color1 = startModel.config.ItemColor;
    //     int color2 = endModel.config.ItemColor;
    //     if (color1.CompareTo(color2) != 0) return -color1.CompareTo(color2);
    //     int code1 = startModel.itemId;
    //     int code2 = endModel.itemId;
    //     if (code1.CompareTo(code2) != 0) return -code1.CompareTo(code2);
    //     return 0;
    // }
    // public void GetOneKeySellModel()
    // {
    //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
    //     if (singlePack == null)
    //         return;
    //     _sellItemlist.Clear();
    //     _lifePotionDict.Clear();
    //     _sameIndexEquipDict.Clear();
    //     _sellItemScorelist.Clear();
    //     playerLv = PlayerDatas.Instance.baseData.LV;
    //     _packModelDict = singlePack.GetAllItems();
    //     foreach (var key in _packModelDict.Keys)
    //     {
    //         GetCanSellEquipList(_packModelDict[key]);
    //         ItemModel itemModel = _packModelDict[key];
    //         if (drugIDs.Contains(itemModel.itemId))
    //         {
    //             if (!_lifePotionDict.ContainsKey(itemModel.config.LV))
    //             {
    //                 List<ItemModel> modellist = new List<ItemModel>();
    //                 modellist.Add(itemModel);
    //                 _lifePotionDict.Add(itemModel.config.LV, modellist);
    //             }
    //             else
    //             {
    //                 _lifePotionDict[itemModel.config.LV].Add(itemModel);
    //             }
    //         }
    //     }
    //     #region 得到可以出售的装备
    //     foreach (var key in _sameIndexEquipDict.Keys)
    //     {
    //         _sellItemScorelist = _sameIndexEquipDict[key].Keys.ToList();
    //         _sellItemScorelist.Sort();
    //         if (_sellItemScorelist.Count > 0)
    //         {
    //             int score = 0;
    //             for (score = _sellItemScorelist.Count - 1; score > -1; score--)
    //             {
    //                 SinglePack equipPack = packModel.GetSinglePack(PackType.Equip);
    //                 ItemModel model = null;
    //                 if (equipPack != null)
    //                 {
    //                     model = equipPack.GetItemByIndex(key);
    //                 }
    //                 var modellist = _sameIndexEquipDict[key][_sellItemScorelist[score]];
    //                 bool remainBetter = true;
    //                 for (var i = 0; i < modellist.Count; i++)
    //                 {
    //                     if (model != null)
    //                     {
    //                         if (remainBetter)
    //                         {
    //                             if (model.score < _sellItemScorelist[score] && IsJobCompatibleItem(model.itemId))
    //                             {
    //                                 _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
    //                                 remainBetter = false;
    //                                 break;
    //                             }
    //                         }
    //                     }
    //                     else
    //                     {
    //                         if (IsJobCompatibleItem(model.itemId))
    //                         {
    //                             if (remainBetter)
    //                             {
    //                                 _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
    //                                 remainBetter = false;
    //                                 break;
    //                             }
    //                         }
    //                     }
    //                 }
    //                 if (!remainBetter)
    //                 {
    //                     break;
    //                 }
    //             }
    //             for (var j = 0; j < _sellItemScorelist.Count; j++)
    //             {
    //                 if (_sameIndexEquipDict[key].ContainsKey(_sellItemScorelist[j]))
    //                 {
    //                     var sellModlelist = _sameIndexEquipDict[key][_sellItemScorelist[j]];
    //                     for (var k = 0; k < sellModlelist.Count; k++)
    //                     {
    //                         _sellItemlist.Add(sellModlelist[k]);
    //                     }
    //                 }
    //             }
    //         }
    //     }
    //     #endregion
    //     List<int> drugLvlist = new List<int>();
    //     drugLvlist.AddRange(_lifePotionDict.Keys.ToList());
    //     drugLvlist.Sort();
    //     for (int i = drugLvlist.Count - 1; i > -1; i--)
    //     {
    //         if (drugLvlist[i] > playerLv)
    //         {
    //             _lifePotionDict.Remove(drugLvlist[i]);
    //         }
    //         else
    //         {
    //             _lifePotionDict.Remove(drugLvlist[i]);
    //             break;
    //         }
    //     }
    //     foreach (var list in _lifePotionDict.Values)
    //     {
    //         for (int i = 0; i < list.Count; i++)
    //         {
    //             _sellItemlist.Add(list[i]);
    //         }
    //     }
    // }
    //得到满足出售条件的装备列表
    // public void GetCanSellEquipList(ItemModel model)
    // {
    //     if (model.config.EquipPlace == 0 || !onekeySellTypes.Contains(model.config.Type))
    //         return;
    //     Dictionary<int, List<ItemModel>> sameScoreDict;
    //     List<ItemModel> sameScorelist;
    //     if (model.config.ItemColor < 3)
    //     {
    //         if (!_sameIndexEquipDict.ContainsKey(model.config.EquipPlace))
    //         {
    //             sameScoreDict = new Dictionary<int, List<ItemModel>>();
    //             sameScorelist = new List<ItemModel>();
    //             sameScorelist.Add(model);
    //             sameScoreDict.Add(model.score, sameScorelist);
    //             _sameIndexEquipDict.Add(model.config.EquipPlace, sameScoreDict);
    //         }
    //         else
    //         {
    //             if (_sameIndexEquipDict[model.config.EquipPlace].ContainsKey(model.score))
    //             {
    //                 _sameIndexEquipDict[model.config.EquipPlace][model.score].Add(model);
    //             }
    //             else
    //             {
    //                 sameScorelist = new List<ItemModel>();
    //                 sameScorelist.Add(model);
    //                 _sameIndexEquipDict[model.config.EquipPlace].Add(model.score, sameScorelist);
    //             }
    //         }
    //     }
    // }
    #endregion
    #region 发送请求
    /// <summary>
    /// 一键出售物品的请求
    /// </summary>
    /// <param name="_oneKeySelllist"></param>
    // public void OneKeySell(List<ItemModel> _oneKeySelllist)
    // {
    //     if (!isPackResetOk || SettingEffectMgr.Instance.isStartOneKeySell) return;
    //     SettingEffectMgr.Instance.isStartOneKeySell = true;
    //     byte[] itemIndexs = new byte[_oneKeySelllist.Count];
    //     int i = 0;
    //     for (i = 0; i < _oneKeySelllist.Count; i++)
    //     {
    //         itemIndexs[i] = (byte)_oneKeySelllist[i].gridIndex;
    //     }
    //     CA311_tagCMSellItem sellItem = new CA311_tagCMSellItem();
    //     sellItem.PackType = (int)PackType.Item;
    //     sellItem.Count = (byte)_oneKeySelllist.Count;
    //     sellItem.ItemIndex = itemIndexs;
    //     GameNetSystem.Instance.SendInfo(sellItem);
    // }
    /// <summary>
    /// 整理包裹物品
    /// </summary>
    /// <param name="type"></param>
    public bool isPackResetOk { get; set; }
    public void ResetPack(PackType type)
    {
        if (lookLineIndex > -1)
        {
            SetLookIndex(null);
        }
        SinglePack singlePack = packModel.GetSinglePack(type);
        if (singlePack != null)
        {
            var packReset = new C070F_tagCItemPackReset();
            packReset.Type = (byte)type;
            packReset.ItemBeginIndex = 0;
            packReset.ItemEndIndex = (ushort)(singlePack.unlockedGridCount - 1);
            GameNetSystem.Instance.SendInfo(packReset); //整理物品
            if (type == PackType.Item)
            {
                isPackResetOk = false;
            }
        }
    }
    #endregion
    #region 查看某个位置的物品
    public event Action lookEquipEvent;
    private int _lookLineIndex = -1;
    public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
    public string lookItemGUID { get; private set; }
    public void SetLookIndex(string guid, int singleRowCount = 5)
    {
        if (string.IsNullOrEmpty(guid) || guid == "")
        {
            lookLineIndex = -1;
        }
        else
        {
            int index = packModel.GetItemByGuid(guid).gridIndex;
            lookLineIndex = index / singleRowCount;
            lookItemGUID = guid;
        }
        if (lookEquipEvent != null)
        {
            lookEquipEvent();
        }
    }
    #endregion
    #region 判断是否有更好的装备替换
    /// <summary>
    /// 获取装备评分最高可提升战力的装备
    /// </summary>
    /// <param name="_places"></param>
    /// <returns></returns>
    // public string GetHighestScoreEquipByPlace(int equipPlace)
    // {
    //     var itemPackage = packModel.GetSinglePack(PackType.Item);
    //     var allItems = itemPackage.GetAllItems();
    //     var putModel = packModel.GetItemByIndex(PackType.Equip, equipPlace);
    //     var guid = string.Empty;
    //     var score = putModel == null ? 0 : putModel.score;
    //     foreach (var item in allItems.Values)
    //     {
    //         if (item.config.EquipPlace == equipPlace)
    //         {
    //             if (!IsOverdue(item.guid)
    //                && (IsJobCompatibleItem(item.itemId)) && item.score > score)
    //             {
    //                 guid = item.guid;
    //                 score = item.score;
    //             }
    //         }
    //     }
    //     return guid;
    // }
    #endregion
    bool IsCanPutOn(ItemModel item)
    {
        if (IsJobCompatibleItem(item.itemId))
        {
            return false;
        }
        int equipPlace = item.config.EquipPlace;
        if (equipPlace == 0 || equipPlace > 17)
        {
            return false;
        }
        var putOnlimitList = item.GetUseData((int)ItemUseDataKey.cancelUseLimit);
        if (!putOnlimitList.IsNullOrEmpty())
        {
            if (putOnlimitList[0] == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public event Action<string> GetBetterEquipEvent; //得到更好的装备 value 物品的实例ID
        return true;
    }
        // public void OnGetEquip(ItemModel item)
    #region 得到物品的品质颜色
    private Dictionary<int, int> wingRefineQualityDict;
    private int[] wingsQualitys;
    private int[] wingsRefineExps;
    public int GetItemQuality(int itemId, Dictionary<int, List<int>> useDataDic = null)
    {
        wingsQualitys = null;
        wingsRefineExps = null;
        ItemConfig itemConfig = ItemConfig.Get(itemId);
        // wingRefineQualityDict = WingRefineAttrConfig.GetWingsQualityModel(itemConfig.LV);
        // if (useDataDic != null)
        // {
        //     if (item == null)
        //     if (useDataDic.ContainsKey(42) && wingRefineQualityDict != null)
        //     {
        //         return;
        //     }
        //     if (item.packType != PackType.Item)
        //     {
        //         return;
        //     }
        //     if (!IsJobCompatibleItem(item.itemId))
        //     {
        //         return;
        //     }
        //     int equipPlace = item.config.EquipPlace;
        //     if ((RoleEquipType)equipPlace == RoleEquipType.Wing)
        //     {
        //         var wing = packModel.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
        //         if (wing == null)
        //         wingsQualitys = wingRefineQualityDict.Keys.ToArray();
        //         wingsRefineExps = wingRefineQualityDict.Values.ToArray();
        //         int i = 0;
        //         for (i = wingsRefineExps.Length - 1; i > -1; i--)
        //         {
        //             if (!SpiritWeaponModel.hasAutoEquipWing)
        //             if (useDataDic[42][0] >= wingsRefineExps[i])
        //             {
        //                 SpiritWeaponModel.hasAutoEquipWing = true;
        //                 ItemOperateUtility.Instance.PutOnItem(item.guid);
        //                 return;
        //                 return wingsQualitys[i];
        //             }
        //         }
        //     }
        //     switch ((RoleEquipType)equipPlace)
        //     {
        //         case RoleEquipType.Weapon:
        //         case RoleEquipType.Weapon2:
        //         case RoleEquipType.Hat:
        //         case RoleEquipType.Clothes:
        //         case RoleEquipType.Belt:
        //         case RoleEquipType.Trousers:
        //         case RoleEquipType.Shoes:
        //         case RoleEquipType.Neck:
        //         case RoleEquipType.FairyCan1:
        //         case RoleEquipType.FairyCan2:
        //         case RoleEquipType.Glove:
        //         case RoleEquipType.Jade:
        //         case RoleEquipType.Wing:
        //         case RoleEquipType.Guard:
        //         case RoleEquipType.PeerlessWeapon1:
        //         case RoleEquipType.PeerlessWeapon2:
        //             if (betterEquipExceptDungeonDict.ContainsKey(PlayerDatas.Instance.baseData.MapID))
        //             {
        //                 if (betterEquipExceptDungeonDict[PlayerDatas.Instance.baseData.MapID].Contains(item.itemId))
        //                 {
        //                     return;
        //                 }
        //             }
        //             SetGetBetterEquipEvent(item);
        //             break;
        //     }
        // }
        return itemConfig.ItemColor;
    }
    #endregion
        private void SetGetBetterEquipEvent(ItemModel model)
    //设置玩家货币显示
    public string OnChangeCoinsUnit(long value)
    {
        return UIHelper.ReplaceLargeNum(value);
    }
    /// <summary>
    /// 装备是否可以提升战力
    /// </summary>
    /// <param name="_itemID"></param>
    /// <param name="_score"></param>
    /// <returns></returns>
    public int IsFightUp(int _itemID, int _score)//-1低级,0不是本职业,1更好
    {
        var config = ItemConfig.Get(_itemID);
        if (config != null)
        {
            // // if (model.isAuction)
            // // {
            // //    return;
            // // }
            // var itemEffectTime = model.GetUseData((int)ItemUseDataKey.createTime);
            // if (!itemEffectTime.IsNullOrEmpty() && itemEffectTime.Count > 0)
            // var index = EquipModel.GetItemServerEquipPlace(_itemID);
            // if (index == -1)
            // {
            //     if (itemEffectTime[0] != 0)
            //     {
            //         var cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(model.guid);
            //         double remainTime = 0;
            //         if (cool != null)
            //         {
            //             remainTime = cool.GetRemainTime();
            //         }
            //         if (remainTime >= 0 && remainTime < 120 && model.config.ExpireTime > 0)
            //         {
            //             return;
            //         }
            //     }
            //     return 0;
            // }
            // if (!equipModel.IsLevelUnLocked(model.config.LV))
            // var item = packModel.GetItemByIndex(PackType.Equip, index);
            // var equipScore = item != null ? item.score : 0;
            // if (IsJobCompatibleItem(_itemID))
            // {
            //     return;
            //     return _score.CompareTo(equipScore);
            // }
            // int isFightUp = IsFightUp(model.itemId, model.score);
            // if (isFightUp != 1)
            // else
            // {
            //     return;
            // }
            // if (GetBetterEquipEvent != null)
            // {
            //     GetBetterEquipEvent(model.guid);
            //     return 0;
            // }
        }
        public event Action<PackType, string> PickItemEvent; //捡起的物品
        return 0;
    }
        //用于过滤道具飘入表现 在不想出现物品飘动的界面 开启界面的时候设置true ,关闭界面设置false
        public bool hidePickItem = false;
        public void RefreshPickItem(PackType type, string itemIDStr)
    // 不包含未开放装备的比较 属于-1
    public int IsFightUpEx(int _itemID, int _score, int _realm)//-1低级,0不是本职业,1更好
    {
        var config = ItemConfig.Get(_itemID);
        if (config != null)
        {
            if (hidePickItem)
                return;
            if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) return;
            //修改后传的是物品id字符串
            if (type != PackType.Item && type != PackType.DogzItem && type != PackType.GatherSoul && type != PackType.RunePack && type != PackType.default1) return;
            if (PickItemEvent != null)
            {
                PickItemEvent(type, itemIDStr);
            }
        }
        Dictionary<int, ItemModel> RealmBetterDict = new Dictionary<int, ItemModel>();
        // public Dictionary<int, ItemModel> CheckBetterEquipByRealm()
        // {
        //     RealmBetterDict.Clear();
        //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
        //     if (singlePack == null) return RealmBetterDict;
        //     int realmLv = PlayerDatas.Instance.baseData.realmLevel;
        //     Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
        //     foreach (var model in pairs.Values)
        //     {
        //         var equipServerIndex = EquipSet.ClientPlaceToServerPlace(new Int2(model.config.LV, model.config.EquipPlace));
        //         if (model.config.EquipPlace > 0
        //             && model.config.EquipPlace != (int)RoleEquipType.Guard
        //             && model.config.RealmLimit <= realmLv
        //             && !IsOverdue(model.guid)
        //             && IsFightUp(model.itemId, model.score) == 1)
        //         {
        //             if (!RealmBetterDict.ContainsKey(equipServerIndex))
        //             {
        //                 RealmBetterDict.Add(equipServerIndex, model);
        //             }
        //             else
        //             {
        //                 if (model.score > RealmBetterDict[equipServerIndex].score)
        //                 {
        //                     RealmBetterDict[equipServerIndex] = model;
        //                 }
        //             }
        //         }
        //     }
        //     return RealmBetterDict;
        // }
        // List<ItemModel> RealmDruglist = new List<ItemModel>();
        // public List<ItemModel> GetDruglistByRealm()
        // {
        //     RealmDruglist.Clear();
        //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
        //     if (singlePack == null) return RealmDruglist;
        //     int realmLv = PlayerDatas.Instance.baseData.realmLevel;
        //     Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
        //     foreach (var model in pairs.Values)
        //     {
        //         if (packModel.CheckIsDrugById(model.itemId))
        //         {
        //             AttrFruitConfig fruitConfig = AttrFruitConfig.Get(model.itemId);
        //             if (!packModel.IsReachMaxUseDrug(fruitConfig)
        //                 && model.config.RealmLimit <= realmLv)
        //             {
        //                 RealmDruglist.Add(model);
        //             }
        //         }
        //     }
        //     return RealmDruglist;
        // }
        #endregion
        #region 物品处于CD中的逻辑处理
        private List<string> itemEffectTimelist = new List<string>(); //key 物品实例ID
        /// <summary>
        /// 物品使用时间限制
        /// </summary>
        public void SetItemEffectCDTime(string guid, int itemID, int getTime, int serverSurplusTime)
        {
            double time = GetTimeOffest(TimeUtility.GetTime((uint)getTime));
            if (time < 0)
            {
                time = 0;
            }
            ItemConfig itemConfig = ItemConfig.Get(itemID);
            if (time >= itemConfig.ExpireTime)
            {
                KnapsackTimeCDMgr.Instance.UnRegister(guid);
                return;
            }
            double remainTime = (serverSurplusTime > 0 ? serverSurplusTime : itemConfig.ExpireTime) - time;
            KnapsackTimeCDMgr.Instance.Register(guid, itemID, remainTime);
        }
        public double GetTimeOffest(DateTime getTime)
        {
            Debug.Log("现在时间:" + TimeUtility.ServerNow + "获得时间:" + getTime);
            //TimeUtility.SyncServerTime();
            TimeSpan t = TimeUtility.ServerNow - getTime;
            Debug.Log("时间差:" + t.TotalSeconds);
            return t.TotalSeconds;
        }
        #endregion
        #region 设置可以一键出售的物品数据
        private int playerLv;
        private Dictionary<int, List<ItemModel>> _lifePotionDict = new Dictionary<int, List<ItemModel>>(); //key 药水等级
        private List<int> _sellItemScorelist = new List<int>();
        private Dictionary<int, Dictionary<int, List<ItemModel>>> _sameIndexEquipDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>();  //存储相同装备位的装备
                                                                                                                                                  // private  _sameEquipScoreDict = new Dictionary<int, List<ItemModel>>(); //存储相同ID中相同装备评分的装备
        private Dictionary<int, ItemModel> _packModelDict;
        private List<ItemModel> _sellItemlist = new List<ItemModel>();
        // public List<ItemModel> GetSellItemList()
        // {
        //     GetOneKeySellModel();
        //     _sellItemlist.Sort(SetSellItemOrder);
        //     return _sellItemlist;
        // }
        // public int SetSellItemOrder(ItemModel startModel, ItemModel endModel)
        // {
        //     bool startIsEquip = IsRealmEquip(startModel.itemId);
        //     bool endIsEquip = IsRealmEquip(endModel.itemId);
        //     if (startIsEquip.CompareTo(endIsEquip) != 0) return -startIsEquip.CompareTo(endIsEquip);
        //     int order1 = startModel.config.Type;
        //     int order2 = endModel.config.Type;
        //     if (order1.CompareTo(order2) != 0) return order1.CompareTo(order2);
        //     int color1 = startModel.config.ItemColor;
        //     int color2 = endModel.config.ItemColor;
        //     if (color1.CompareTo(color2) != 0) return -color1.CompareTo(color2);
        //     int code1 = startModel.itemId;
        //     int code2 = endModel.itemId;
        //     if (code1.CompareTo(code2) != 0) return -code1.CompareTo(code2);
        //     return 0;
        // }
        // public void GetOneKeySellModel()
        // {
        //     SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
        //     if (singlePack == null)
        //         return;
        //     _sellItemlist.Clear();
        //     _lifePotionDict.Clear();
        //     _sameIndexEquipDict.Clear();
        //     _sellItemScorelist.Clear();
        //     playerLv = PlayerDatas.Instance.baseData.LV;
        //     _packModelDict = singlePack.GetAllItems();
        //     foreach (var key in _packModelDict.Keys)
        //     {
        //         GetCanSellEquipList(_packModelDict[key]);
        //         ItemModel itemModel = _packModelDict[key];
        //         if (drugIDs.Contains(itemModel.itemId))
        //         {
        //             if (!_lifePotionDict.ContainsKey(itemModel.config.LV))
        //             {
        //                 List<ItemModel> modellist = new List<ItemModel>();
        //                 modellist.Add(itemModel);
        //                 _lifePotionDict.Add(itemModel.config.LV, modellist);
        //             }
        //             else
        //             {
        //                 _lifePotionDict[itemModel.config.LV].Add(itemModel);
        //             }
        //         }
        //     }
        //     #region 得到可以出售的装备
        //     foreach (var key in _sameIndexEquipDict.Keys)
        //     {
        //         _sellItemScorelist = _sameIndexEquipDict[key].Keys.ToList();
        //         _sellItemScorelist.Sort();
        //         if (_sellItemScorelist.Count > 0)
        //         {
        //             int score = 0;
        //             for (score = _sellItemScorelist.Count - 1; score > -1; score--)
        //             {
        //                 SinglePack equipPack = packModel.GetSinglePack(PackType.Equip);
        //                 ItemModel model = null;
        //                 if (equipPack != null)
        //                 {
        //                     model = equipPack.GetItemByIndex(key);
        //                 }
        //                 var modellist = _sameIndexEquipDict[key][_sellItemScorelist[score]];
        //                 bool remainBetter = true;
        //                 for (var i = 0; i < modellist.Count; i++)
        //                 {
        //                     if (model != null)
        //                     {
        //                         if (remainBetter)
        //                         {
        //                             if (model.score < _sellItemScorelist[score] && IsJobCompatibleItem(model.itemId))
        //                             {
        //                                 _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
        //                                 remainBetter = false;
        //                                 break;
        //                             }
        //                         }
        //                     }
        //                     else
        //                     {
        //                         if (IsJobCompatibleItem(model.itemId))
        //                         {
        //                             if (remainBetter)
        //                             {
        //                                 _sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
        //                                 remainBetter = false;
        //                                 break;
        //                             }
        //                         }
        //                     }
        //                 }
        //                 if (!remainBetter)
        //                 {
        //                     break;
        //                 }
        //             }
        //             for (var j = 0; j < _sellItemScorelist.Count; j++)
        //             {
        //                 if (_sameIndexEquipDict[key].ContainsKey(_sellItemScorelist[j]))
        //                 {
        //                     var sellModlelist = _sameIndexEquipDict[key][_sellItemScorelist[j]];
        //                     for (var k = 0; k < sellModlelist.Count; k++)
        //                     {
        //                         _sellItemlist.Add(sellModlelist[k]);
        //                     }
        //                 }
        //             }
        //         }
        //     }
        //     #endregion
        //     List<int> drugLvlist = new List<int>();
        //     drugLvlist.AddRange(_lifePotionDict.Keys.ToList());
        //     drugLvlist.Sort();
        //     for (int i = drugLvlist.Count - 1; i > -1; i--)
        //     {
        //         if (drugLvlist[i] > playerLv)
        //         {
        //             _lifePotionDict.Remove(drugLvlist[i]);
        //         }
        //         else
        //         {
        //             _lifePotionDict.Remove(drugLvlist[i]);
        //             break;
        //         }
        //     }
        //     foreach (var list in _lifePotionDict.Values)
        //     {
        //         for (int i = 0; i < list.Count; i++)
        //         {
        //             _sellItemlist.Add(list[i]);
        //         }
        //     }
        // }
        //得到满足出售条件的装备列表
        // public void GetCanSellEquipList(ItemModel model)
        // {
        //     if (model.config.EquipPlace == 0 || !onekeySellTypes.Contains(model.config.Type))
        //         return;
        //     Dictionary<int, List<ItemModel>> sameScoreDict;
        //     List<ItemModel> sameScorelist;
        //     if (model.config.ItemColor < 3)
        //     {
        //         if (!_sameIndexEquipDict.ContainsKey(model.config.EquipPlace))
        //         {
        //             sameScoreDict = new Dictionary<int, List<ItemModel>>();
        //             sameScorelist = new List<ItemModel>();
        //             sameScorelist.Add(model);
        //             sameScoreDict.Add(model.score, sameScorelist);
        //             _sameIndexEquipDict.Add(model.config.EquipPlace, sameScoreDict);
        //         }
        //         else
        //         {
        //             if (_sameIndexEquipDict[model.config.EquipPlace].ContainsKey(model.score))
        //             {
        //                 _sameIndexEquipDict[model.config.EquipPlace][model.score].Add(model);
        //             }
        //             else
        //             {
        //                 sameScorelist = new List<ItemModel>();
        //                 sameScorelist.Add(model);
        //                 _sameIndexEquipDict[model.config.EquipPlace].Add(model.score, sameScorelist);
        //             }
        //         }
        //     }
        // }
        #endregion
        #region 发送请求
        /// <summary>
        /// 一键出售物品的请求
        /// </summary>
        /// <param name="_oneKeySelllist"></param>
        // public void OneKeySell(List<ItemModel> _oneKeySelllist)
        // {
        //     if (!isPackResetOk || SettingEffectMgr.Instance.isStartOneKeySell) return;
        //     SettingEffectMgr.Instance.isStartOneKeySell = true;
        //     byte[] itemIndexs = new byte[_oneKeySelllist.Count];
        //     int i = 0;
        //     for (i = 0; i < _oneKeySelllist.Count; i++)
        //     {
        //         itemIndexs[i] = (byte)_oneKeySelllist[i].gridIndex;
        //     }
        //     CA311_tagCMSellItem sellItem = new CA311_tagCMSellItem();
        //     sellItem.PackType = (int)PackType.Item;
        //     sellItem.Count = (byte)_oneKeySelllist.Count;
        //     sellItem.ItemIndex = itemIndexs;
        //     GameNetSystem.Instance.SendInfo(sellItem);
        // }
        /// <summary>
        /// 整理包裹物品
        /// </summary>
        /// <param name="type"></param>
        public bool isPackResetOk { get; set; }
        public void ResetPack(PackType type)
        {
            if (lookLineIndex > -1)
            {
                SetLookIndex(null);
            }
            SinglePack singlePack = packModel.GetSinglePack(type);
            if (singlePack != null)
            {
                var packReset = new C070F_tagCItemPackReset();
                packReset.Type = (byte)type;
                packReset.ItemBeginIndex = 0;
                packReset.ItemEndIndex = (ushort)(singlePack.unlockedGridCount - 1);
                GameNetSystem.Instance.SendInfo(packReset); //整理物品
                if (type == PackType.Item)
                {
                    isPackResetOk = false;
                }
            }
        }
        #endregion
        #region 查看某个位置的物品
        public event Action lookEquipEvent;
        private int _lookLineIndex = -1;
        public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
        public string lookItemGUID { get; private set; }
        public void SetLookIndex(string guid, int singleRowCount = 5)
        {
            if (string.IsNullOrEmpty(guid) || guid == "")
            {
                lookLineIndex = -1;
            }
            else
            {
                int index = packModel.GetItemByGuid(guid).gridIndex;
                lookLineIndex = index / singleRowCount;
                lookItemGUID = guid;
            }
            if (lookEquipEvent != null)
            {
                lookEquipEvent();
            }
        }
        #endregion
        #region 判断是否有更好的装备替换
        /// <summary>
        /// 获取装备评分最高可提升战力的装备
        /// </summary>
        /// <param name="_places"></param>
        /// <returns></returns>
        // public string GetHighestScoreEquipByPlace(int equipPlace)
        // {
        //     var itemPackage = packModel.GetSinglePack(PackType.Item);
        //     var allItems = itemPackage.GetAllItems();
        //     var putModel = packModel.GetItemByIndex(PackType.Equip, equipPlace);
        //     var guid = string.Empty;
        //     var score = putModel == null ? 0 : putModel.score;
        //     foreach (var item in allItems.Values)
        //     {
        //         if (item.config.EquipPlace == equipPlace)
        //         {
        //             if (!IsOverdue(item.guid)
        //                && (IsJobCompatibleItem(item.itemId)) && item.score > score)
        //             {
        //                 guid = item.guid;
        //                 score = item.score;
        //             }
        //         }
        //     }
        //     return guid;
        // }
        #endregion
        #region 背包整理后好的同类型最好的装备
        Dictionary<int, Dictionary<int, ItemModel>> itemModelDict = new Dictionary<int, Dictionary<int, ItemModel>>();  // key1 装备位置索引 key2 背包位置索引
        public void ClearSortedBetterEquip()
        {
            itemModelDict.Clear();
        }
        public void SetBagSortBetterEquipList(ItemModel itemModel)
        {
            if (itemModel == null || itemModel.packType != PackType.Item) return;
            if (!IsCanPutOn(itemModel)) return;
            int equipPlace = itemModel.config.EquipPlace;
            if (!itemModelDict.ContainsKey(equipPlace))
            {
                var dict = new Dictionary<int, ItemModel>();
                if (IsFightUp(itemModel.itemId, itemModel.score) == 1)
                {
                    dict.Add(itemModel.gridIndex, itemModel);
                    itemModelDict.Add(equipPlace, dict);
                }
            }
            else
            {
                if (IsFightUp(itemModel.itemId, itemModel.score) == 1)
                {
                    itemModelDict[equipPlace].Add(itemModel.gridIndex, itemModel);
                }
            }
        }
        public ItemModel GetBagSortBetterEquip(int equipPlace, int index)
        {
            ItemModel itemModel = null;
            if (itemModelDict.ContainsKey(equipPlace))
            {
                itemModelDict[equipPlace].TryGetValue(index, out itemModel);
            }
            return itemModel;
        }
        bool IsCanPutOn(ItemModel item)
        {
            if (IsJobCompatibleItem(item.itemId))
            {
                return false;
            }
            int equipPlace = item.config.EquipPlace;
            if (equipPlace == 0 || equipPlace > 17)
            {
                return false;
            }
            var putOnlimitList = item.GetUseData((int)ItemUseDataKey.cancelUseLimit);
            if (!putOnlimitList.IsNullOrEmpty())
            {
                if (putOnlimitList[0] == 1)
                {
                    return true;
                }
            }
            return PlayerDatas.Instance.baseData.realmLevel >= item.config.RealmLimit;
        }
        #endregion
        #region 得到物品的品质颜色
        private Dictionary<int, int> wingRefineQualityDict;
        private int[] wingsQualitys;
        private int[] wingsRefineExps;
        public int GetItemQuality(int itemId, Dictionary<int, List<int>> useDataDic = null)
        {
            wingsQualitys = null;
            wingsRefineExps = null;
            ItemConfig itemConfig = ItemConfig.Get(itemId);
            // wingRefineQualityDict = WingRefineAttrConfig.GetWingsQualityModel(itemConfig.LV);
            // if (useDataDic != null)
            // var index = EquipModel.GetItemServerEquipPlace(_itemID);
            // if (index == -1)
            // {
            //     if (useDataDic.ContainsKey(42) && wingRefineQualityDict != null)
            //     {
            //         wingsQualitys = wingRefineQualityDict.Keys.ToArray();
            //         wingsRefineExps = wingRefineQualityDict.Values.ToArray();
            //         int i = 0;
            //         for (i = wingsRefineExps.Length - 1; i > -1; i--)
            //         {
            //             if (useDataDic[42][0] >= wingsRefineExps[i])
            //             {
            //                 return wingsQualitys[i];
            //             }
            //         }
            //     }
            //     return 0;
            // }
            return itemConfig.ItemColor;
        }
        #endregion
        //设置玩家货币显示
        public string OnChangeCoinsUnit(ulong value)
        {
            return UIHelper.ReplaceLargeNum(value);
            // var item = packModel.GetItemByIndex(PackType.Equip, index);
            // var equipScore = item != null ? item.score : 0;
            // if (IsJobCompatibleItem(_itemID))
            // {
            //     if (_realm > PlayerDatas.Instance.baseData.realmLevel)
            //         return -1;
            //     return _score.CompareTo(equipScore);
            // }
            // else
            // {
            //     return 0;
            // }
        }
        /// <summary>
        /// 装备是否可以提升战力
        /// </summary>
        /// <param name="_itemID"></param>
        /// <param name="_score"></param>
        /// <returns></returns>
        public int IsFightUp(int _itemID, int _score)//-1低级,0不是本职业,1更好
        return 0;
    }
    #region 物品是否过期
    public bool IsOverdue(string guid)
    {
        var item = packModel.GetItemByGuid(guid);
        if (item == null)
        {
            var config = ItemConfig.Get(_itemID);
            if (config != null)
            {
                // var index = EquipModel.GetItemServerEquipPlace(_itemID);
                // if (index == -1)
                // {
                //     return 0;
                // }
                // var item = packModel.GetItemByIndex(PackType.Equip, index);
                // var equipScore = item != null ? item.score : 0;
                // if (IsJobCompatibleItem(_itemID))
                // {
                //     return _score.CompareTo(equipScore);
                // }
                // else
                // {
                //     return 0;
                // }
            }
            return 0;
            return false;
        }
        // 不包含未开放装备的比较 属于-1
        public int IsFightUpEx(int _itemID, int _score, int _realm)//-1低级,0不是本职业,1更好
        if (item.isAuction)
        {
            var config = ItemConfig.Get(_itemID);
            if (config != null)
            {
                // var index = EquipModel.GetItemServerEquipPlace(_itemID);
                // if (index == -1)
                // {
                //     return 0;
                // }
                // var item = packModel.GetItemByIndex(PackType.Equip, index);
                // var equipScore = item != null ? item.score : 0;
                // if (IsJobCompatibleItem(_itemID))
                // {
                //     if (_realm > PlayerDatas.Instance.baseData.realmLevel)
                //         return -1;
                //     return _score.CompareTo(equipScore);
                // }
                // else
                // {
                //     return 0;
                // }
            }
            return 0;
            return false;//item.auctionSurplusTime < 0;
        }
        #region 物品是否过期
        public bool IsOverdue(string guid)
        else
        {
            var item = packModel.GetItemByGuid(guid);
            if (item == null)
            var isoverdue = false;
            switch ((ItemTimeType)item.config.EndureReduceType)
            {
                return false;
                case ItemTimeType.EquipedTime:
                    isoverdue = item.GetUseDataFirstValue(44) > 0 && item.overdueSurplusTime < 0;
                    break;
                case ItemTimeType.RealityTime:
                    isoverdue = item.overdueSurplusTime < 0;
                    break;
            }
            if (item.isAuction)
            {
                return false;//item.auctionSurplusTime < 0;
            }
            else
            {
                var isoverdue = false;
                switch ((ItemTimeType)item.config.EndureReduceType)
                {
                    case ItemTimeType.EquipedTime:
                        isoverdue = item.GetUseDataFirstValue(44) > 0 && item.overdueSurplusTime < 0;
                        break;
                    case ItemTimeType.RealityTime:
                        isoverdue = item.overdueSurplusTime < 0;
                        break;
                }
                return isoverdue;
            }
        }
        #endregion
        public bool IsJobCompatibleItem(int itemId)
        {
            var config = ItemConfig.Get(itemId);
            return config != null && (config.JobLimit == 0 || config.JobLimit == PlayerDatas.Instance.baseData.Job);
        }
        public bool IsRealmEquip(int itemId)
        {
            if (!ItemConfig.HasKey(itemId))
            {
                return false;
            }
            var config = ItemConfig.Get(itemId);
            return config.Type >= 101 && config.Type <= 112;
        }
        public bool IsWing(int itemId)
        {
            if (!ItemConfig.HasKey(itemId))
            {
                return false;
            }
            var config = ItemConfig.Get(itemId);
            return config.Type == 113 || config.Type == 39 || config.Type == 52;
        }
        public bool IsDogzEquip(int itemId)
        {
            if (!ItemConfig.HasKey(itemId))
            {
                return false;
            }
            var config = ItemConfig.Get(itemId);
            return config.Type >= 119 && config.Type <= 123;
        }
        public bool IsSpiritWeapon(int itemId)
        {
            if (!ItemConfig.HasKey(itemId))
            {
                return false;
            }
            var config = ItemConfig.Get(itemId);
            return config.Type >= 113 && config.Type <= 117;
        }
        public bool IsSuitEquip(int itemId)
        {
            if (!ItemConfig.HasKey(itemId))
            {
                return false;
            }
            var config = ItemConfig.Get(itemId);
            return config.SuiteiD > 0 && config.Type >= 101 && config.Type <= 112;
        }
        // public bool IsThanksItem(int itemID)
        // {
        //     if (AssistThanksGiftConfig.Get(itemID) == null)
        //     {
        //         return false;
        //     }
        //     return true;
        // }
        // public int GetSpecialSpiritPropertyValue(int itemId)
        // {
        //     var config = SpiritWeaponConfig.Get(itemId);
        //     if (config == null)
        //     {
        //         return 0;
        //     }
        //     var propertyId = 0;
        //     var propertyValue = 0;
        //     for (var i = 0; i < config.AttrIDList.Length; i++)
        //     {
        //         var id = config.AttrIDList[i];
        //         if (id == 79 || id == 80)
        //         {
        //             propertyId = id;
        //             propertyValue = config.AttrValueList[i];
        //             break;
        //         }
        //     }
        //     if (propertyId == 0)
        //     {
        //         return 0;
        //     }
        //     Equation.Instance.Clear();
        //     Equation.Instance.AddKeyValue("maxOOPValue", propertyValue);
        //     var maxLevel = 100;
        //     if (specialSpiritPropertyMaxLevels.ContainsKey(config.Level))
        //     {
        //         maxLevel = specialSpiritPropertyMaxLevels[config.Level];
        //     }
        //     Equation.Instance.AddKeyValue("lv", Mathf.Min(maxLevel, PlayerDatas.Instance.baseData.LV));
        //     return Equation.Instance.Eval<int>(specialSpiritPropertyFormula[propertyId]);
        // }
        // public int GetSpecialSpiritPropertyMaxLevel(int itemId)
        // {
        //     var config = SpiritWeaponConfig.Get(itemId);
        //     if (config == null)
        //     {
        //         return 0;
        //     }
        //     var maxLevel = 0;
        //     if (specialSpiritPropertyMaxLevels.ContainsKey(config.Level))
        //     {
        //         maxLevel = specialSpiritPropertyMaxLevels[config.Level];
        //     }
        //     return maxLevel;
        // }
        //装备对比,用于非实际装备简单比较 是否需要此装备
        // public bool IsSatisfyEquipBetterEquip(int itemID)
        // {
        //     if (!IsRealmEquip(itemID))
        //     {
        //         return false;
        //     }
        //     var itemConfig = ItemConfig.Get(itemID);
        //     if (itemConfig.JobLimit != 0 && itemConfig.JobLimit != PlayerDatas.Instance.baseData.Job)
        //     {
        //         return false;
        //     }
        //     var equipSet = equipModel.GetEquipSet(itemConfig.LV);
        //     if (!equipSet.IsSlotUnLocked(itemConfig.EquipPlace))
        //     {
        //         return false;
        //     }
        //     var equipGuid = equipModel.GetEquip(new Int2(itemConfig.LV, itemConfig.EquipPlace));
        //     if (string.IsNullOrEmpty(equipGuid))
        //     {
        //         return true;
        //     }
        //     var itemModel = packModel.GetItemByGuid(equipGuid);
        //     if (itemModel == null)
        //     {
        //         return true;
        //     }
        //     if (itemConfig.ItemColor > itemModel.config.ItemColor)
        //     {
        //         return true;
        //     }
        //     return itemModel.config.SuiteiD == 0 && itemConfig.SuiteiD != 0;
        // }
        public Action OnGetItem;    //CommonGetItemWin界面关闭时触发
        public string getItemInfo { get; private set; }  //通用显示获得的界面信息
        public string getItemBtnText { get; private set; }  //通用显示获得的界面按钮文字 默认确定
        public int closeSeconds { get; private set; } // 关闭倒计时时间 如果传0代表手动关闭
        public bool isNameShow { get; private set; } // 是否展示物品名字
        // 如果同时有多种奖励封包,同一个事件归集,不同事件直接顶掉显示最新
        public Dictionary<int, Item> totalShowItems = new Dictionary<int, Item>();
        public event Action OnGetItemShowEvent;
        private string getItemEventName;
        // 通用显示获得的物品
        public void ShowGetItem(List<Item> items, string info = "", int seconds = 3, string btnName = "", Action func = null, bool isNameShow = true, string eventName = "default")
        {
            if (getItemEventName != eventName)
            {
                if (UIManager.Instance.IsOpenedInList<CommonGetItemWin>())
                {
                    //----------------------记得改立即关闭
                    UIManager.Instance.CloseWindow<CommonGetItemWin>();
                }
                totalShowItems.Clear();
                getItemEventName = eventName;
            }
            //相同ID 合并数量显示
            for (int i = 0; i < items.Count; i++)
            {
                var id = items[i].id;
                if (totalShowItems.ContainsKey(id))
                {
                    totalShowItems[id] = new Item(id, items[i].countEx + totalShowItems[id].countEx, items[i].bind, items[i].quality);
                }
                else
                {
                    totalShowItems.Add(id, items[i]);
                }
            }
            getItemInfo = info;
            OnGetItem = func;
            if (btnName == "")
                btnName = Language.Get("PopConfirmWin_OK");
            getItemBtnText = btnName;
            closeSeconds = seconds;
            this.isNameShow = isNameShow;
            OnGetItemShowEvent?.Invoke();
            if (!UIManager.Instance.IsOpenedInList<CommonGetItemWin>())
            {
                UIManager.Instance.OpenWindow<CommonGetItemWin>();
            }
        }
        //可以指定打开的窗口
        public void ShowGetItemEx<T>(List<Item> items, string info = "", int seconds = 3, string btnName = "", Action func = null, bool isNameShow = true, string eventName = "default") where T : UIBase
        {
            if (getItemEventName != eventName)
            {
                if (UIManager.Instance.IsOpenedInList<T>())
                {
                    //----------------------记得改立即关闭
                    UIManager.Instance.CloseWindow<T>();
                }
                totalShowItems.Clear();
                getItemEventName = eventName;
            }
            //相同ID 合并数量显示
            for (int i = 0; i < items.Count; i++)
            {
                var id = items[i].id;
                if (totalShowItems.ContainsKey(id))
                {
                    totalShowItems[id] = new Item(id, items[i].countEx + totalShowItems[id].countEx, items[i].bind, items[i].quality);
                }
                else
                {
                    totalShowItems.Add(id, items[i]);
                }
            }
            getItemInfo = info;
            OnGetItem = func;
            if (btnName == "")
                btnName = Language.Get("PopConfirmWin_OK");
            getItemBtnText = btnName;
            closeSeconds = seconds;
            this.isNameShow = isNameShow;
            OnGetItemShowEvent?.Invoke();
            if (!UIManager.Instance.IsOpenedInList<T>())
            {
                UIManager.Instance.OpenWindow<T>();
            }
        }
        public void ClearGetItem()
        {
            //不清理物品,下次收到数据会自动清理,只改事件方便打开界面测试
            getItemEventName = "";
            return isoverdue;
        }
    }
    #endregion
    public bool IsJobCompatibleItem(int itemId)
    {
        var config = ItemConfig.Get(itemId);
        return config != null && (config.JobLimit == 0 || config.JobLimit == PlayerDatas.Instance.baseData.Job);
    }
    public bool IsRealmEquip(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        var config = ItemConfig.Get(itemId);
        return config.Type >= 101 && config.Type <= 112;
    }
    public bool IsWing(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        var config = ItemConfig.Get(itemId);
        return config.Type == 113 || config.Type == 39 || config.Type == 52;
    }
    public bool IsDogzEquip(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        var config = ItemConfig.Get(itemId);
        return config.Type >= 119 && config.Type <= 123;
    }
    public bool IsSpiritWeapon(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        var config = ItemConfig.Get(itemId);
        return config.Type >= 113 && config.Type <= 117;
    }
    public bool IsSuitEquip(int itemId)
    {
        if (!ItemConfig.HasKey(itemId))
        {
            return false;
        }
        var config = ItemConfig.Get(itemId);
        return config.SuiteiD > 0 && config.Type >= 101 && config.Type <= 112;
    }
    // public bool IsThanksItem(int itemID)
    // {
    //     if (AssistThanksGiftConfig.Get(itemID) == null)
    //     {
    //         return false;
    //     }
    //     return true;
    // }
    // public int GetSpecialSpiritPropertyValue(int itemId)
    // {
    //     var config = SpiritWeaponConfig.Get(itemId);
    //     if (config == null)
    //     {
    //         return 0;
    //     }
    //     var propertyId = 0;
    //     var propertyValue = 0;
    //     for (var i = 0; i < config.AttrIDList.Length; i++)
    //     {
    //         var id = config.AttrIDList[i];
    //         if (id == 79 || id == 80)
    //         {
    //             propertyId = id;
    //             propertyValue = config.AttrValueList[i];
    //             break;
    //         }
    //     }
    //     if (propertyId == 0)
    //     {
    //         return 0;
    //     }
    //     Equation.Instance.Clear();
    //     Equation.Instance.AddKeyValue("maxOOPValue", propertyValue);
    //     var maxLevel = 100;
    //     if (specialSpiritPropertyMaxLevels.ContainsKey(config.Level))
    //     {
    //         maxLevel = specialSpiritPropertyMaxLevels[config.Level];
    //     }
    //     Equation.Instance.AddKeyValue("lv", Mathf.Min(maxLevel, PlayerDatas.Instance.baseData.LV));
    //     return Equation.Instance.Eval<int>(specialSpiritPropertyFormula[propertyId]);
    // }
    // public int GetSpecialSpiritPropertyMaxLevel(int itemId)
    // {
    //     var config = SpiritWeaponConfig.Get(itemId);
    //     if (config == null)
    //     {
    //         return 0;
    //     }
    //     var maxLevel = 0;
    //     if (specialSpiritPropertyMaxLevels.ContainsKey(config.Level))
    //     {
    //         maxLevel = specialSpiritPropertyMaxLevels[config.Level];
    //     }
    //     return maxLevel;
    // }
    //装备对比,用于非实际装备简单比较 是否需要此装备
    // public bool IsSatisfyEquipBetterEquip(int itemID)
    // {
    //     if (!IsRealmEquip(itemID))
    //     {
    //         return false;
    //     }
    //     var itemConfig = ItemConfig.Get(itemID);
    //     if (itemConfig.JobLimit != 0 && itemConfig.JobLimit != PlayerDatas.Instance.baseData.Job)
    //     {
    //         return false;
    //     }
    //     var equipSet = equipModel.GetEquipSet(itemConfig.LV);
    //     if (!equipSet.IsSlotUnLocked(itemConfig.EquipPlace))
    //     {
    //         return false;
    //     }
    //     var equipGuid = equipModel.GetEquip(new Int2(itemConfig.LV, itemConfig.EquipPlace));
    //     if (string.IsNullOrEmpty(equipGuid))
    //     {
    //         return true;
    //     }
    //     var itemModel = packModel.GetItemByGuid(equipGuid);
    //     if (itemModel == null)
    //     {
    //         return true;
    //     }
    //     if (itemConfig.ItemColor > itemModel.config.ItemColor)
    //     {
    //         return true;
    //     }
    //     return itemModel.config.SuiteiD == 0 && itemConfig.SuiteiD != 0;
    // }
    #region 获得英雄物品展示立绘
    public List<int> poplhHeroIdList = new List<int>();
    public void SetHeroList(List<Item> items)
    {
        if (items.IsNullOrEmpty())
            return;
        foreach (var item in items)
        {
            int itemId = item.id;
            if (HeroConfig.HasKey(itemId) &&
                HeroConfig.Get(itemId).Quality >= HappyXBModel.Instance.lhQuality)
            {
                poplhHeroIdList.Add(itemId);
            }
        }
    }
    public void ShowHeroLHWin(List<Item> items)
    {
        SetHeroList(items);
        if (poplhHeroIdList.Count > 0)
        {
            if (!UIManager.Instance.IsOpenedInList<HeroShowLHWin>())
            {
                UIManager.Instance.OpenWindow<HeroShowLHWin>();
            }
        }
    }
    #endregion
    public Action OnGetItem;    //CommonGetItemWin界面关闭时触发
    public string getItemInfo { get; private set; }  //通用显示获得的界面信息
    public string getItemBtnText { get; private set; }  //通用显示获得的界面按钮文字 默认确定
    public int closeSeconds { get; private set; } // 关闭倒计时时间 如果传0代表手动关闭
    public bool isNameShow { get; private set; } // 是否展示物品名字
    // 如果同时有多种奖励封包,同一个事件归集,不同事件直接顶掉显示最新
    public Dictionary<int, Item> totalShowItems = new Dictionary<int, Item>();
    public event Action OnGetItemShowEvent;
    private string getItemEventName;
    // 通用显示获得的物品
    public void ShowGetItem(List<Item> items, string eventName = "default", bool isNameShow = true)
    {
        if (getItemEventName != eventName)
        {
            if (UIManager.Instance.IsOpenedInList<CommonGetItemWin>())
            {
                //----------------------记得改立即关闭
                UIManager.Instance.CloseWindow<CommonGetItemWin>();
            }
            totalShowItems.Clear();
            getItemEventName = eventName;
        }
        //相同ID 合并数量显示
        for (int i = 0; i < items.Count; i++)
        {
            var id = items[i].id;
            if (totalShowItems.ContainsKey(id))
            {
                totalShowItems[id] = new Item(id, items[i].countEx + totalShowItems[id].countEx, items[i].bind, items[i].quality);
            }
            else
            {
                totalShowItems.Add(id, items[i]);
            }
        }
        this.isNameShow = isNameShow;
        OnGetItemShowEvent?.Invoke();
        if (!UIManager.Instance.IsOpenedInList<CommonGetItemWin>())
        {
            UIManager.Instance.OpenWindow<CommonGetItemWin>();
        }
        ShowHeroLHWin(items);//有传奇以上英雄显示立绘
    }
    //可以指定打开的窗口
    public void ShowGetItemEx<T>(List<Item> items, string info = "", int seconds = 3, string btnName = "", Action func = null, bool isNameShow = true, string eventName = "default") where T : UIBase
    {
        if (getItemEventName != eventName)
        {
            if (UIManager.Instance.IsOpenedInList<T>())
            {
                //----------------------记得改立即关闭
                UIManager.Instance.CloseWindow<T>();
            }
            totalShowItems.Clear();
            getItemEventName = eventName;
        }
        //相同ID 合并数量显示
        for (int i = 0; i < items.Count; i++)
        {
            var id = items[i].id;
            if (totalShowItems.ContainsKey(id))
            {
                totalShowItems[id] = new Item(id, items[i].countEx + totalShowItems[id].countEx, items[i].bind, items[i].quality);
            }
            else
            {
                totalShowItems.Add(id, items[i]);
            }
        }
        getItemInfo = info;
        OnGetItem = func;
        if (btnName == "")
            btnName = Language.Get("PopConfirmWin_OK");
        getItemBtnText = btnName;
        closeSeconds = seconds;
        this.isNameShow = isNameShow;
        OnGetItemShowEvent?.Invoke();
        if (!UIManager.Instance.IsOpenedInList<T>())
        {
            UIManager.Instance.OpenWindow<T>();
        }
        ShowHeroLHWin(items);//有传奇以上英雄显示立绘
    }
    public void ClearGetItem()
    {
        //不清理物品,下次收到数据会自动清理,只改事件方便打开界面测试
        getItemEventName = "";
    }
    public bool UseItem(string guid, int useCnt = 1, int extra = 0)
    {
        var item = packModel.GetItemByGuid(guid);
        if (item == null)
        {
            return false;
        }
        var error = 0;
        if (CanUseItem(guid, useCnt, out error))
        {
            UseItemSendServer(guid, useCnt, extra);
            return true;
        }
        else
        {
            switch (error)
            {
                case 1:
                    SysNotifyMgr.Instance.ShowTip("EverydayUseLimit");
                    break;
                case 2:
                    SysNotifyMgr.Instance.ShowTip("UseCntLimit");
                    break;
                case 3:
                    SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_749572");
                    break;
                default:
                    break;
            }
            return false;
        }
    }
    public bool CanUseItem(string guid, int useCnt, out int error)
    {
        var item = packModel.GetItemByGuid(guid);
        if (item == null)
        {
            error = 999;
            return false;
        }
        if (item.config.Type == 145 && item.config.CDTime > 0)
        {
            var createTime = item.GetUseDataFirstValue((int)ItemUseDataKey.createTime);
            if (createTime > 0)
            {
                DateTime useTime;
                if (item.config.CDTypeEx == 1)
                {
                    //itemConfig.CDTime 为天,过0点可用
                    useTime = TimeUtility.GetTime((uint)createTime).AddDays(item.config.CDTime);
                    useTime = TimeUtility.GetDayStartTime(useTime.Year, useTime.Month, useTime.Day);
                }
                else
                {
                    useTime = TimeUtility.GetTime((uint)createTime).AddSeconds(item.config.CDTime);
                }
                if (TimeUtility.ServerNow < useTime)
                {
                    error = 3;
                    return false;
                }
            }
        }
        var usedCountToday = packModel.GetItemUsedTimesToday(item.itemId);
        if (item.config.MaxSkillCnt > 0 && item.config.MaxSkillCnt <= usedCountToday)
        {
            error = 1;
            return false;
        }
        //var usedCountTotal = packModel.GetItemTotalUsedTimes(item.itemId);
        // var fruitConfig = AttrFruitConfig.Get(item.itemId);
        // if (fruitConfig != null)
        // {
        //     var limitTimes = 0;
        //     if (fruitConfig.FuncID == 2)
        //     {
        //         limitTimes = alchemyModel.GetAlchemyDrugUseLimit(item.itemId);
        //     }
        //     else
        //     {
        //         limitTimes = fruitConfig.basicUseLimit;
        //     }
        //     if (usedCountTotal >= limitTimes || useCnt > limitTimes)
        //     {
        //         error = 1;
        //         return false;
        //     }
        // }
        error = 0;
        return true;
    }
    void UseItemSendServer(string guid, int useCnt, int extra)
    {
        var itemModel = packModel.GetItemByGuid(guid);
        if (itemModel == null)
        {
            return;
        }
        var useItem = new CA323_tagCMUseItems();
        useItem.ItemIndex = (byte)itemModel.gridIndex;
        useItem.UseCnt = (ushort)useCnt;
        useItem.ExData = (uint)extra;
        GameNetSystem.Instance.SendInfo(useItem); //使用物品
    }
}