yyl
2 天以前 973edc44a04dceb8b48a32ca912e6167f86189d4
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
 
public partial class PlayerPropertyConfig : ConfigBase<int, PlayerPropertyConfig>
{
    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>> m_PlayerPropertyDict = new Dictionary<int, List<int>>();
    public static Dictionary<int, List<int>> playerPropertyDict
    {
        get
        {
            if (m_PlayerPropertyDict.IsNullOrEmpty())
                RefreshShowDict();
            return m_PlayerPropertyDict;
        }
    }
 
    public static int[] inheritAttrs = new int[] { 13, 14, 15 };
 
 
    //不同的功能表调用对应自己的功能含义和使用方式,如阵容光环配置就用在对应计算层
    public static int[] basePerAttrs = new int[] { 16, 17, 18 };
 
    public static int[] baseAttrs = new int[] { 6, 7, 8 };
 
    public static Dictionary<int, int> baseAttr2perDict = new Dictionary<int, int>()
    { 
        { 6,16 },
        { 7,17 },
        { 8,18 }
    };
 
    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, true);
    }
 
    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;
    }
}