using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
namespace Snxxz.UI
|
{
|
public class CalculateSkillGetAttrHurtUtility : Singleton<CalculateSkillGetAttrHurtUtility>
|
{
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
private Dictionary<int, int> legendAttrDict = new Dictionary<int, int>();
|
|
public CalculateSkillGetAttrHurtUtility()
|
{
|
playerPack.RefreshItemCountAct += UpdateItem;
|
UpdateSkillHurt();
|
}
|
|
private void UpdateItem(PackType type, int index, int id)
|
{
|
switch(type)
|
{
|
case PackType.JadeDynastyEquip:
|
UpdateSkillHurt();
|
break;
|
}
|
}
|
|
private void UpdateSkillHurt()
|
{
|
legendAttrDict.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(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<int,int> attrDict)
|
{
|
attrDict = new Dictionary<int, int>();
|
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;
|
}
|
}
|
}
|