using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Snxxz.UI { public class CalculateSkillGetAttrHurtUtility : Singleton { PackModel playerPack { get { return ModelCenter.Instance.GetModel(); } } private Dictionary legendAttrDict = new Dictionary(); public CalculateSkillGetAttrHurtUtility() { playerPack.refreshItemCountEvent += UpdateItem; UpdateSkillHurt(); } private void UpdateItem(PackType type, int index, int id) { switch(type) { case PackType.JadeDynastyEquip: UpdateSkillHurt(); break; } } private void UpdateSkillHurt() { legendAttrDict.Clear(); SinglePack singlePack = playerPack.GetSinglePack(PackType.JadeDynastyEquip); if (singlePack == null) return; var dict = singlePack.GetAllItems(); foreach (var model in dict.Values) { var legendIds = model.GetUseDataModel((int)ItemUseDataKey.legendAttrID); var legendValues = model.GetUseDataModel((int)ItemUseDataKey.legendAttrValue); if (legendIds != null && legendValues != null) { for(int i = 0; i < legendIds.Count; i++) { int attrId = legendIds[i]; int attrValue = legendValues[i]; switch ((AttrEnum)attrId) { case AttrEnum.SkillAddPerA: case AttrEnum.SkillAddPerB: case AttrEnum.SkillAddPerC: case AttrEnum.SkillAddPerD: case AttrEnum.SkillAddPerE: case AttrEnum.SkillAddPerF: case AttrEnum.SkillAddPerG: if(!legendAttrDict.ContainsKey(attrId)) { legendAttrDict.Add(attrId, attrValue); } else { legendAttrDict[attrId] += attrValue; } break; } } } } } public bool TryGetAttrDictBySkill(int _skillId,out Dictionary attrDict) { attrDict = new Dictionary(); var attrIds = GeneralDefine.GetAttrIdsBySkill(_skillId); if(attrIds != null) { foreach(var attrId in attrIds) { if(legendAttrDict.ContainsKey(attrId)) { int attrValue = legendAttrDict[attrId]; attrDict.Add(attrId,attrValue); } } } return attrDict.Count > 0; } } }