hch
6 天以前 65b10f63d1fcf6696df105e9922a12b894be32af
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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;
    }
}