少年修仙传客户端代码仓库
hch
2024-12-16 9377811d0ba27047e1e5ec2348a28eba1033d59d
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, April 01, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Text;
using System.Collections.Generic;
 
namespace vnxbqy.UI
{
 
    public class TipItemDescriptionWidget : MonoBehaviour
    {
 
        [SerializeField] Text m_Description;
        [SerializeField] Text m_UseState;
 
        ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
        RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } }
 
        public void Display(int itemId)
        {
            var config = ItemConfig.Get(itemId);
            var description = config.Description;
            if (description.Contains("{Exp}"))
            {
                var expValue = tipsModel.GetAddExpValue(config.EffectValueA1, config.EffectValueB1);
                description = description.Replace("{Exp}", UIHelper.ReplaceLargeNum(expValue));
            }
            if (description.Contains("{FightPower}"))
            {
                var fightPower = tipsModel.GetFightPower(itemId);
                description = description.Replace("{FightPower}", fightPower.ToString());
            }
            if (description.Contains("{ShareNum}"))
            {
                var shareNumDes = tipsModel.GetShareNumItemDes(itemId);
                description = description.Replace("{ShareNum}", shareNumDes);
            }
            if (description.Contains("{Rune}"))
            {
                var unlockRunes = runeModel.GetUnlockRunes();
                List<int> runeTypes = new List<int>();
                var sb = new StringBuilder();
                for (int i = 0; i < unlockRunes.Count; i++)
                {
                    if (!runeModel.IsExistInRandomRunes(itemId, unlockRunes[i]))
                    {
                        continue;
                    }
                    var itemConfig = ItemConfig.Get(unlockRunes[i]);
                    var runeConfig = RuneConfig.Get(unlockRunes[i]);
                    if (runeTypes.Contains(runeConfig.AttrType[0]))
                    {
                        continue;
                    }
                    runeTypes.Add(runeConfig.AttrType[0]);
                    if (itemConfig != null)
                    {
                        sb.Append(itemConfig.ItemName);
                        sb.Append("\n");
                    }
                }
                description = description.Replace("{Rune}", sb.ToString());
            }
 
            m_Description.text = description;
        }
 
        public void DisplayUseState(int usedCount, int maxCount)
        {
            if (maxCount > 0)
            {
                m_UseState.SetActive(true);
                m_UseState.text = Language.Get("BoxUseCntTip", StringUtility.Contact(usedCount, "/", maxCount));
                m_UseState.color = UIHelper.GetUIColor(usedCount >= maxCount ? TextColType.Red : TextColType.Green, false);
            }
            else
            {
                m_UseState.SetActive(false);
            }
        }
 
    }
 
}