| | |
| | | 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 normalGSFormula;
|
| | | var GSFormulaConfig = FuncConfigConfig.Get("EquipGSFormula");
|
| | | normalGSFormula = GSFormulaConfig.Numerical1;
|
| | |
|
| | |
|
| | | 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()
|
| | | var equipSkillScoreJson = JsonMapper.ToObject(GSFormulaConfig.Numerical4);
|
| | | foreach (var key in equipSkillScoreJson.Keys)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | var skillId = 0;
|
| | | int.TryParse(key, out skillId);
|
| | | if (skillId != 0)
|
| | | {
|
| | | equipSkillScores[skillId] = (int)equipSkillScoreJson[key];
|
| | | }
|
| | | 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()));
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
| | | }
|
| | |
|
| | | void OnBeforePlayerDataInitialize()
|
| | | var baseAttr = JsonMapper.ToObject(GSFormulaConfig.Numerical2);
|
| | | if (baseAttr.IsArray)
|
| | | {
|
| | | isPackResetOk = true;
|
| | | ClearSortedBetterEquip();
|
| | | for (int i = 0; i < baseAttr.Count; i++)
|
| | | {
|
| | | equipBaseProperties.Add(int.Parse(baseAttr[i].ToString()));
|
| | | }
|
| | | }
|
| | |
|
| | | #region 计算装备评分
|
| | |
|
| | | class EquipSorceProperties
|
| | |
|
| | |
|
| | | 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)
|
| | | {
|
| | | 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))
|
| | | {
|
| | | 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 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 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];
|
| | | }
|
| | |
|
| | | properties[id] = value;
|
| | | }
|
| | |
|
| | |
|
| | | return skillScore + Equation.Instance.Eval<int>(normalGSFormula);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | |
| | | 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 - 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)
|
| | | 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 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 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]];
|
| | | }
|
| | | }
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
|
| | | 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
|
| | |
|
| | | #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;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | public event Action<string> GetBetterEquipEvent; //得到更好的装备 value 物品的实例ID
|
| | | return true;
|
| | | }
|
| | |
|
| | | // public void OnGetEquip(ItemModel item)
|
| | | #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)
|
| | | // {
|
| | | // 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(ulong 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;
|
| | | // }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | |
|
| | | 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)
|
| | | // 不包含未开放装备的比较 属于-1
|
| | | public int IsFightUpEx(int _itemID, int _score, int _realm)//-1低级,0不是本职业,1更好
|
| | | {
|
| | | var config = ItemConfig.Get(_itemID);
|
| | | if (config != null)
|
| | | {
|
| | | 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;
|
| | | // }
|
| | |
|
| | |
|
| | |
|
| | | 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 = "";
|
| | | }
|
| | |
|
| | | |
| | | }
|