少年修仙传客户端代码仓库
client_linchunjie
2019-03-14 eedeb8a020fce13e0e63ad7c57adfdff7578e875
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
using System;
using System.Collections.Generic;
 
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 GetPropertyDescription(int propertyId, int value)
    {
        return GetPropertyDescription(propertyId, value, 1, false);
    }
 
    public static string GetPropertyDescription(int propertyId, int value, int decimalCount, bool largeValue)
    {
        var config = Get(propertyId);
        if (config == null)
        {
            return string.Empty;
        }
 
        float _result = 0f;
 
        if (config.ISPercentage == 0)
        {
            _result = value;
        }
        else if (config.ISPercentage == 1)
        {
            _result = (float)Math.Round(value / 100f, decimalCount);
        }
        else if (config.ISPercentage == 2)
        {
            _result = (float)Math.Round(value / 100f, decimalCount);
        }
 
        var label = string.Empty;
        if (largeValue)
        {
            label = UIHelper.ReplaceLargeNum(_result);
        }
        else
        {
            label = _result.ToString();
        }
 
        return config.ISPercentage == 1 ? (label + "%") : label;
    }
 
}