hch
2 天以前 6ae4b14b7fb6640ec805f070a1f0f691941c6917
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
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
 
public class BeautyMMTalentEffectCell : CellView
{
    [SerializeField] Text lvText;
    [SerializeField] ImageEx lvBGImg;
    [SerializeField] Text nameText;
    [SerializeField] Text[] talentTexts;
    [SerializeField] Image activeImg;
    public void Display(int rank, int mmID)
    {
        lvText.text = (rank*BeautyMMManager.Instance.needLVForTalent).ToString();
        var lvValue = BeautyMMManager.Instance.GetMMLV(mmID);
        var isActive = BeautyMMManager.Instance.isActiveMM(mmID);
        bool isRankActive = false;
        if (isActive && lvValue/BeautyMMManager.Instance.needLVForTalent >= rank)
        {
            isRankActive = true;
        }
        lvBGImg.gray = !isRankActive;
        ShowTalent(mmID, rank, isRankActive);
        activeImg.SetActive(isRankActive && lvValue / BeautyMMManager.Instance.needLVForTalent == rank);
        nameText.text = isRankActive ? Language.Get($"BeautyMMLVName{rank + 1}") : UIHelper.AppendColor(TextColType.NavyGray, Language.Get($"BeautyMMLVName{rank + 1}"));
    }
 
 
    void ShowTalent(int mmID, int rank, bool isRankActive)
    {
        var mmConfig = BeautyConfig.Get(mmID);
        //先显示天赋属性,再显示天赋特性
        var attrs = GetMMTalentAttrForUI(mmConfig, rank);
        int talentIndex = 0;
        if (attrs.IsNullOrEmpty())
        {
            talentIndex = 0;
        }
        else
        {
            foreach (var attr in attrs)
            {
                if (talentIndex < talentTexts.Length)
                {
                    talentTexts[talentIndex].SetActive(true);
                    string format = "{0}" + UIHelper.AppendColor(TextColType.Green, "+{1}");
                    talentTexts[talentIndex].text = PlayerPropertyConfig.GetFullDescription(attr.Key, attr.Value, format);
                }
                else
                {
                    break;
                }
                talentIndex++;
            }
        }
 
 
        var talentValue = GetMMTalentEffectForUI(mmConfig, rank);
        for (int i = talentIndex; i < talentTexts.Length; i++)
        {
            if (i == talentIndex && mmConfig.EffType != 0)
            {
                //天赋效果约定最多一个
                talentTexts[talentIndex].SetActive(true);
                switch (mmConfig.EffType)
                {
                    case 1:
                        talentTexts[i].text = Language.Get($"BeautyMMTalent1", talentValue);
                        break;
                    case 2:
                        talentTexts[i].text = Language.Get($"BeautyMMTalent2", talentValue / 100, ItemConfig.Get(mmConfig.EffTypeValue).ItemName);
                        break;
                    case 3:
                        talentTexts[i].text = Language.Get($"BeautyMMTalent3", talentValue);
                        break;
                    case 4:
                        talentTexts[i].text = Language.Get($"BeautyMMTalent4", ItemConfig.Get(mmConfig.EffTypeValue).ItemName, talentValue);
                        break;
                }
            }
            else
            {
                talentTexts[i].SetActive(false);
            }
        }
 
        //置灰
        if (!isRankActive)
        {
            for (int i = 0; i < talentTexts.Length; i++)
            {
                talentTexts[i].text = UIHelper.AppendColor(TextColType.NavyGray, talentTexts[i].text);
            }
        }
 
    }
 
    Dictionary<int, long> GetMMTalentAttrForUI(BeautyConfig config, int rank)
    {
        var _dict = new Dictionary<int, long>();
        //初始天赋属性
        for (int i = 0; i < config.TalentAttrIDList.Length; i++)
        {
            _dict[config.TalentAttrIDList[i]] = config.TalentAttrValueList[i];
        }
 
        //按x级好感度提升一级天赋效果
        if (rank > 0)
        {
            for (int i = 0; i < config.TalentAttrIDList.Length; i++)
            {
                _dict[config.TalentAttrIDList[i]] += rank * config.TalentPerLVAddList[i];
            }
        }
        return _dict;
    }
 
    int GetMMTalentEffectForUI(BeautyConfig config, int rank)
    {
        //初始天赋效果
        int _effect = config.EffValue;
        if (rank > 0)
        {
            _effect += rank * config.EffPerLVAdd;
        }
        return _effect;
    }
 
 
}