using System;
|
using System.Collections.Generic;
|
|
public partial class PlayerPropertyConfig : IConfigPostProcess
|
{
|
private static Dictionary<int, List<PlayerPropertyConfig>> m_PropCfgs = new Dictionary<int, List<PlayerPropertyConfig>>();
|
|
public void OnConfigParseCompleted()
|
{
|
List<PlayerPropertyConfig> list = null;
|
m_PropCfgs.TryGetValue(type, out list);
|
if (list != null)
|
{
|
list.Add(this);
|
}
|
else
|
{
|
list = new List<PlayerPropertyConfig>();
|
list.Add(this);
|
m_PropCfgs.Add(type, list);
|
}
|
}
|
|
public static List<PlayerPropertyConfig> GetPropByType(int type)
|
{
|
List<PlayerPropertyConfig> list = null;
|
m_PropCfgs.TryGetValue(type, out list);
|
return list;
|
}
|
|
public static string GetPropertyDescription(int propertyId, int value)
|
{
|
return GetPropertyDescription(propertyId, value, 1, false);
|
}
|
|
public static string GetPropertyDescription(int propertyId, int value, int decimalCount, bool largeValue)
|
{
|
var config = Get(propertyId);
|
if (config == null)
|
{
|
return string.Empty;
|
}
|
|
float _result = 0f;
|
|
if (config.ISPercentage == 0)
|
{
|
_result = value;
|
}
|
else if (config.ISPercentage == 1)
|
{
|
_result = (float)Math.Round(value / 100f, decimalCount);
|
}
|
else if (config.ISPercentage == 2)
|
{
|
_result = (float)Math.Round(value / 100f, decimalCount);
|
}
|
|
var label = string.Empty;
|
if (largeValue)
|
{
|
label = UIHelper.ReplaceLargeNum(_result);
|
}
|
else
|
{
|
label = _result.ToString();
|
}
|
|
return config.ISPercentage == 1 ? (label + "%") : label;
|
}
|
|
}
|