using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text.RegularExpressions;
|
|
public partial class PlayerPropertyConfig : ConfigBase<int, PlayerPropertyConfig>
|
{
|
// 按显示类型分
|
private static Dictionary<int, List<int>> m_PlayerPropertyDict = new Dictionary<int, List<int>>();
|
public static Dictionary<int, List<int>> playerPropertyDict
|
{
|
get
|
{
|
if (m_PlayerPropertyDict.IsNullOrEmpty())
|
RefreshShowDict();
|
return m_PlayerPropertyDict;
|
}
|
}
|
|
private static int[] m_inheritAttrs;//攻防血 继承的百分比
|
public static int[] inheritAttrs
|
{
|
get
|
{
|
if (m_inheritAttrs.IsNullOrEmpty())
|
{
|
if (playerPropertyDict.ContainsKey(5))
|
{
|
m_inheritAttrs = playerPropertyDict[5].ToArray();
|
}
|
}
|
return m_inheritAttrs;
|
}
|
}
|
|
private static int[] m_basePerAttrs; //攻防血 加成百分比
|
public static int[] basePerAttrs
|
{
|
get
|
{
|
if (m_basePerAttrs.IsNullOrEmpty())
|
{
|
if (playerPropertyDict.ContainsKey(6))
|
{
|
m_basePerAttrs = playerPropertyDict[6].ToArray();
|
}
|
}
|
return m_basePerAttrs;
|
}
|
}
|
|
public const int baseType = 1; //基础属性
|
public const int fightType = 2; //战斗属性
|
public const int fightAntiType = 3; //战斗抗性
|
public const int specialType = 4; //特殊属性
|
private static Dictionary<int, List<int>> RefreshShowDict()
|
{
|
if (m_PlayerPropertyDict.IsNullOrEmpty())
|
{
|
var keys = GetKeys();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
int id = keys[i];
|
int showType = Get(id).showType;
|
if (showType == 0) //为0时不显示
|
continue;
|
if (!m_PlayerPropertyDict.ContainsKey(showType))
|
{
|
m_PlayerPropertyDict[showType] = new List<int> { id };
|
}
|
else
|
{
|
m_PlayerPropertyDict[showType].Add(id);
|
}
|
}
|
foreach (var showType in m_PlayerPropertyDict.Keys)
|
{
|
m_PlayerPropertyDict[showType].Sort(cmp);
|
}
|
}
|
return m_PlayerPropertyDict;
|
}
|
|
static int cmp(int id1, int id2)
|
{
|
var config1 = Get(id1);
|
var config2 = Get(id2);
|
|
return config1.showSequence.CompareTo(config2.showSequence);
|
}
|
|
|
|
public static string GetFullDescription(Int2 property)
|
{
|
return GetFullDescription(property.x, property.y);
|
}
|
|
public static string GetFullDescription(int id, long value, string format="{0}+{1}")
|
{
|
var config = Get(id);
|
if (config == null)
|
{
|
return string.Empty;
|
}
|
|
if (config.ShowName.Contains("%s"))
|
{
|
// if (id == 52)
|
// {
|
// return Regex.Replace(config.ShowName, "%s", (value * 0.0001f).ToString("f2"));
|
// }
|
// else
|
{
|
return Regex.Replace(config.ShowName, "%s", value.ToString());
|
}
|
}
|
else
|
{
|
return string.Format(format, config.ShowName, GetValueDescription(id, value));
|
}
|
}
|
|
public static string GetValueDescription(int id, long value)
|
{
|
return GetValueDescription(id, value, false);
|
}
|
|
public static string GetValueDescription(int id, long value, bool largeValue)
|
{
|
var config = Get(id);
|
if (config == null)
|
{
|
return string.Empty;
|
}
|
|
double result = 0f;
|
if (config.ISPercentage == 0)
|
{
|
result = value;
|
}
|
else if (config.ISPercentage == 1)
|
{
|
result = (double)Math.Round(value / 100f, config.decimalCount);
|
}
|
else if (config.ISPercentage == 2)
|
{
|
result = (double)Math.Round(value / 100f, config.decimalCount);
|
}
|
|
var label = string.Empty;
|
if (largeValue)
|
{
|
label = UIHelper.ReplaceLargeNum(result);
|
}
|
else
|
{
|
label = result.ToString();
|
}
|
|
return config.ISPercentage == 1 ? (label + "%") : label;
|
}
|
}
|