少年修仙传客户端代码仓库
hch
2 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, September 29, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
 
    public class MonsterNameColor
    {
 
        static Dictionary<E_MonsterType, List<MonsterNameColorConfig>> monsterNameColors = null;
 
        public static Color GetColor(E_MonsterType _monsterType, int _heroLevel, int _monsterLevel)
        {
            if (monsterNameColors == null)
            {
                monsterNameColors = new Dictionary<E_MonsterType, List<MonsterNameColorConfig>>();
                var allConfig = MonsterNameColorConfig.GetValues();
                foreach (var config in allConfig)
                {
                    var monsterType = (E_MonsterType)config.MonsterType;
                    List<MonsterNameColorConfig> colors = null;
                    if (!monsterNameColors.ContainsKey(monsterType))
                    {
                        colors = new List<MonsterNameColorConfig>();
                        monsterNameColors[monsterType] = colors;
                    }
                    else
                    {
                        colors = monsterNameColors[monsterType];
                    }
 
                    colors.Add(config);
                }
 
                foreach (var key in monsterNameColors.Keys)
                {
                    var colors = monsterNameColors[key];
                    colors.Sort(
                        (MonsterNameColorConfig a, MonsterNameColorConfig b) =>
                        {
                            return a.LevelDelta < b.LevelDelta ? -1 : 1;
                        }
                        );
                }
 
            }
 
            int levelDelta = _monsterLevel - _heroLevel;
            List<MonsterNameColorConfig> nameColors = null;
            if (monsterNameColors.TryGetValue(_monsterType, out nameColors))
            {
                for (int i = 0; i < nameColors.Count; i++)
                {
                    var config = nameColors[i];
                    if (levelDelta < config.LevelDelta || i == nameColors.Count - 1)
                    {
                        return new Color(config.Color.x, config.Color.y, config.Color.z, 1);
                    }
                }
 
                return Color.white;
            }
            else
            {
                return Color.white;
            }
 
        }
 
 
 
 
 
    }
 
}