using System.Collections.Generic;
|
|
public class AttributeManager : GameSystemManager<AttributeManager>
|
{
|
public Dictionary<int, long> totalAttrDict = new Dictionary<int, long>();
|
public void OpenTotalAttributeWin(Dictionary<int, long> totalAttrDict, int functionOrder = 0)
|
{
|
this.totalAttrDict = totalAttrDict;
|
if (!UIManager.Instance.IsOpened<TotalAttributeWin>())
|
{
|
UIManager.Instance.OpenWindow<TotalAttributeWin>(functionOrder);
|
}
|
}
|
|
public readonly int SimpleAttributeMaxRowCnt = 2;
|
public Dictionary<int, long> simpleAttrDict = new Dictionary<int, long>();
|
public List<int> simpleAttrSortList = new List<int>();
|
public string simpleAttrTitleName = string.Empty;
|
public void OpenSimpleAttributeWin(Dictionary<int, long> simpleAttrs, string titleNameKey = "")
|
{
|
simpleAttrDict = FilterValidAttributes(simpleAttrs);
|
simpleAttrSortList = SortAttrId(simpleAttrDict);
|
simpleAttrTitleName = Language.Get(string.IsNullOrEmpty(titleNameKey) ? "AttributeTitle00" : titleNameKey);
|
if (!UIManager.Instance.IsOpened<SimpleAttributeWin>())
|
{
|
UIManager.Instance.OpenWindow<SimpleAttributeWin>();
|
}
|
}
|
|
// 命格专用
|
public Dictionary<int, int> skillDic = new Dictionary<int, int>();
|
public List<int> skillList = new List<int>();
|
public void OpenMinggeSimpleAttributeWin(Dictionary<int, long> simpleAttrs, Dictionary<int, int> skills)
|
{
|
|
if (skills.IsNullOrEmpty())
|
{
|
OpenSimpleAttributeWin(simpleAttrs, "AttributeTitle03");
|
return;
|
}
|
simpleAttrDict = FilterValidAttributes(simpleAttrs);
|
simpleAttrSortList = SortAttrId(simpleAttrDict);
|
simpleAttrTitleName = Language.Get("AttributeTitle03");
|
skillDic = skills;
|
skillList = new List<int>(skillDic.Keys);
|
skillList.Sort();
|
if (!UIManager.Instance.IsOpened<SimpleMinggeAttributeWin>())
|
{
|
UIManager.Instance.OpenWindow<SimpleMinggeAttributeWin>();
|
}
|
}
|
|
|
public bool TryGetInfoBySkillID(int skillTypeID, int lv, out string name, out string desc)
|
{
|
name = string.Empty;
|
desc = string.Empty;
|
if (!SkillConfig.HasKey(skillTypeID))
|
return false;
|
SkillConfig config = SkillConfig.Get(skillTypeID + lv - 1);
|
name = Language.Get("OtherPlayerDetail14", Language.Get($"MinggeSkillType_{skillTypeID}"), lv);
|
desc = config.Description;
|
return true;
|
}
|
|
|
/// <summary>
|
/// 过滤有效的属性:移除value<=0或showType<=0或不在配置表中的项
|
/// </summary>
|
private Dictionary<int, long> FilterValidAttributes(Dictionary<int, long> dict)
|
{
|
if (dict == null)
|
return null;
|
|
var result = new Dictionary<int, long>();
|
foreach (var kvp in dict)
|
{
|
if (!PlayerPropertyConfig.HasKey(kvp.Key))
|
continue;
|
PlayerPropertyConfig config = PlayerPropertyConfig.Get(kvp.Key);
|
if (kvp.Value > 0 && config.showType > 0 && config.showType < 5)
|
{
|
result.Add(kvp.Key, kvp.Value);
|
}
|
}
|
return result;
|
}
|
|
/// <summary>
|
/// 根据PlayerPropertyConfig的showType和showSequence对属性ID进行排序
|
/// 排序规则:先按showType升序,showType相同按showSequence升序,showSequence相同按ID升序
|
/// </summary>
|
private List<int> SortAttrId(Dictionary<int, long> dict)
|
{
|
if (dict == null)
|
return null;
|
var list = new List<int>(dict.Keys);
|
list.Sort((a, b) =>
|
{
|
bool hasKeyA = PlayerPropertyConfig.HasKey(a);
|
bool hasKeyB = PlayerPropertyConfig.HasKey(b);
|
// 如果一个在表中一个不在,将不在表的排在后面
|
if (hasKeyA != hasKeyB)
|
return hasKeyA.CompareTo(hasKeyB);
|
|
var configA = PlayerPropertyConfig.Get(a);
|
var configB = PlayerPropertyConfig.Get(b);
|
int showTypeA = configA?.showType ?? 0;
|
int showTypeB = configB?.showType ?? 0;
|
|
if (showTypeA != showTypeB)
|
return showTypeA.CompareTo(showTypeB);
|
|
int showSequenceA = configA?.showSequence ?? 0;
|
int showSequenceB = configB?.showSequence ?? 0;
|
if (showSequenceA != showSequenceB)
|
return showSequenceA.CompareTo(showSequenceB);
|
|
return a.CompareTo(b);
|
});
|
return list;
|
}
|
}
|