少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-27 be5d159c18c1aea1fd9f310bcedb7afa05923e10
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
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;
    }
 
}