using System;
|
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
|
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 GetFullDescription(Int2 property)
|
{
|
return GetFullDescription(property.x, property.y);
|
}
|
|
public static string GetFullDescription(int id, int value)
|
{
|
var config = Get(id);
|
if (config == null)
|
{
|
return string.Empty;
|
}
|
|
if (config.Name.Contains("%s"))
|
{
|
if (id == 52)
|
{
|
return Regex.Replace(config.Name, "%s", (value * 0.0001f).ToString("f2"));
|
}
|
else
|
{
|
return Regex.Replace(config.Name, "%s", value.ToString());
|
}
|
}
|
else
|
{
|
return string.Format("{0} +{1}", config.Name, GetValueDescription(id, value));
|
}
|
}
|
|
public static string GetValueDescription(Int2 property)
|
{
|
return GetValueDescription(property.x, property.y);
|
}
|
|
public static string GetValueDescription(int id, int value)
|
{
|
return GetValueDescription(id, value, false);
|
}
|
|
public static string GetValueDescription(int id, int value, bool largeValue)
|
{
|
var config = Get(id);
|
if (config == null)
|
{
|
return string.Empty;
|
}
|
|
var result = 0f;
|
if (config.ISPercentage == 0)
|
{
|
result = value;
|
}
|
else if (config.ISPercentage == 1)
|
{
|
result = (float)Math.Round(value / 100f, config.decimalCount);
|
}
|
else if (config.ISPercentage == 2)
|
{
|
result = (float)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;
|
}
|
|
}
|