yyl
15 小时以前 ad14e2586cd13c52b30e1cc481724a1e09407f6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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<PlayerPropertyConfig>> m_PropCfgs = new Dictionary<int, List<PlayerPropertyConfig>>();
    private static Dictionary<int, List<int>> outputDict = new Dictionary<int, List<int>>();
 
    protected override 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 Dictionary<int, List<int>> GetShowDict()
    {
        if (outputDict.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 (!outputDict.ContainsKey(showType))
                {
                    outputDict[showType] = new List<int> { id };
                }
                else
                {
                    outputDict[showType].Add(id);
                }
            }
            var outputList = outputDict.Keys.ToList();
            for (int i = 0; i < outputList.Count; i++)
            {
                int showType = outputList[i];
                outputDict[showType].Sort(cmp);
            }
        }
        return outputDict;
    }
 
    static int cmp(int id1, int id2)
    {
        var config1 = Get(id1);
        var config2 = Get(id2);
 
        return config1.showSequence.CompareTo(config2.showSequence);
    }
 
    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, long 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(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;
    }
}