| | |
| | |
|
| | | public class ItemLogicUtility : Singleton<ItemLogicUtility>
|
| | | {
|
| | | private string normalGSFormula;
|
| | | // private string normalGSFormula;
|
| | |
|
| | |
|
| | | private List<int> equipBaseProperties = new List<int>();
|
| | | Dictionary<int, int> equipSkillScores = new Dictionary<int, int>();
|
| | | // 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>(); } }
|
| | |
| | |
|
| | | public void Init()
|
| | | {
|
| | | var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
|
| | | normalGSFormula = GSFormulaConfig.Numerical1;
|
| | | // var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
|
| | | // normalGSFormula = GSFormulaConfig.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 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()));
|
| | | }
|
| | | }
|
| | | // var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
|
| | | // if (baseAttr.IsArray)
|
| | | // {
|
| | | // for (int i = 0; i < baseAttr.Count; i++)
|
| | | // {
|
| | | // equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
|
| | | // }
|
| | | // }
|
| | |
|
| | |
|
| | |
|
| | |
| | | void OnBeforePlayerDataInitialize()
|
| | | {
|
| | | isPackResetOk = true;
|
| | | ClearSortedBetterEquip();
|
| | | }
|
| | |
|
| | | #region 计算装备评分
|
| | |
| | |
|
| | | }
|
| | |
|
| | | 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)
|
| | | // {
|
| | |
| | | /// <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)
|
| | | private void CalculateEquipAttr(int itemId, EquipSorceProperties properties)
|
| | | {
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | 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]);
|
| | | }
|
| | | 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]];
|
| | | }
|
| | | }
|
| | | 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
|
| | |
|
| | |
|
| | | private bool CheckIsExtendGrid(int itemId)
|
| | | {
|
| | | SinglePack singlePack = packModel.GetSinglePack(PackType.Item);
|
| | | if (singlePack == null) return false;
|
| | |
|
| | | int startLockIndex = singlePack.unlockedGridCount - PackManager.Instance.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)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// <param name="packType 背包类型"></param>
|
| | | /// <param name="itemId 物品ID"></param>
|
| | | /// <param name="needCount 需要数量"></param>
|
| | | /// <param name="needTips 是否需要提示"></param>
|
| | | /// <param name="needTips">0 不响应 1 弹提示 2 弹获取途径tips</param>
|
| | | /// <returns></returns>
|
| | | public static bool CheckItemCount(PackType packType, int itemId, int needCount, bool needTips)
|
| | | public static bool CheckItemCount(PackType packType, int itemId, long needCount, int needTips = 0)
|
| | | {
|
| | | if (needCount <= 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | int haveCount = PackManager.Instance.GetItemCountByID(packType, itemId);
|
| | | var haveCount = PackManager.Instance.GetItemCountByID(packType, itemId);
|
| | |
|
| | | bool isEnough = haveCount >= needCount;
|
| | |
|
| | | if (!isEnough && needTips)
|
| | | if (!isEnough)
|
| | | {
|
| | | var itemConfig = ItemConfig.Get(itemId);
|
| | |
|
| | | if (null != itemConfig)
|
| | | if (needTips == 1)
|
| | | {
|
| | | // 是否有获取途径
|
| | | // 是 弹出获取途径
|
| | | // 否 显示物品数量不足
|
| | | // SysNotifyMgr.Instance.ShowTip();
|
| | | SysNotifyMgr.Instance.ShowTip("ItemNotEnough", itemId);
|
| | | }
|
| | | else if (needTips == 2)
|
| | | {
|
| | | ItemTipUtility.Show(itemId, true);
|
| | | }
|
| | | }
|
| | |
|
| | | return isEnough;
|
| | | }
|
| | |
|
| | | public static bool CheckCurrencyCount(int moneyType, ulong needCount, bool needTips)
|
| | | {
|
| | | if (needCount <= 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | ulong haveCount = UIHelper.GetMoneyCnt(moneyType);
|
| | |
|
| | | bool isEnough = haveCount >= needCount;
|
| | |
|
| | | if (!isEnough && needTips)
|
| | | {
|
| | | // 是否有获取途径
|
| | | // 是 弹出获取途径
|
| | | // 否 显示物品数量不足
|
| | | // SysNotifyMgr.Instance.ShowTip();
|
| | | }
|
| | |
|
| | | return isEnough;
|
| | | }
|
| | |
|
| | | public event Action<string> GetBetterEquipEvent; //得到更好的装备 value 物品的实例ID
|
| | |
|
| | |
| | | // }
|
| | | #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)
|
| | | {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 得到物品的品质颜色
|
| | | private Dictionary<int, int> wingRefineQualityDict;
|
| | |
| | | #endregion
|
| | |
|
| | | //设置玩家货币显示
|
| | | public string OnChangeCoinsUnit(ulong value)
|
| | | public string OnChangeCoinsUnit(long value)
|
| | | {
|
| | | return UIHelper.ReplaceLargeNum(value);
|
| | | }
|
| | |
| | |
|
| | | // 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; } //通用显示获得的界面信息
|
| | |
| | | {
|
| | | UIManager.Instance.OpenWindow<CommonGetItemWin>();
|
| | | }
|
| | |
|
| | | ShowHeroLHWin(items);//有传奇以上英雄显示立绘
|
| | | }
|
| | |
|
| | | //可以指定打开的窗口
|
| | |
| | | {
|
| | | UIManager.Instance.OpenWindow<T>();
|
| | | }
|
| | |
|
| | | ShowHeroLHWin(items);//有传奇以上英雄显示立绘
|
| | | }
|
| | | public void ClearGetItem()
|
| | | {
|