少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using System.Collections;
using System.Collections.Generic;
using System.Text;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class ViewPetHorseStoneCell : CellView
    {
        [SerializeField] ItemCell m_Item;
        [SerializeField] Slider m_Slider;
        [SerializeField] Text m_UseNum;
        [SerializeField] Text m_Property;
 
        static Dictionary<int, int> propertyDict = new Dictionary<int, int>();
 
        static StringBuilder textBuilder = new StringBuilder();
 
        public void Display(int itemId, int count)
        {
            var config = ItemConfig.Get(itemId);
            if (config == null)
            {
                return;
            }
            ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)count);
            m_Item.Init(cellModel);
 
            m_Item.button.RemoveAllListeners();
            m_Item.button.AddListener(() =>
            {
                ItemTipUtility.Show(itemId);
            });
 
            var stoneConfig = AttrFruitConfig.Get(itemId);
            if (stoneConfig != null)
            {
                m_Slider.value = (float)count / stoneConfig.basicUseLimit;
                m_UseNum.text = StringUtility.Contact(count, "/", stoneConfig.basicUseLimit);
            }
 
            propertyDict.Clear();
 
            if (config.Effect1 != 0)
            {
                propertyDict.Add(config.Effect1, config.EffectValueA1);
            }
            if (config.Effect2 != 0)
            {
                propertyDict.Add(config.Effect2, config.EffectValueA2);
            }
            if (config.Effect3 != 0)
            {
                propertyDict.Add(config.Effect3, config.EffectValueA3);
            }
            if (config.Effect4 != 0)
            {
                propertyDict.Add(config.Effect4, config.EffectValueA4);
            }
            if (config.Effect5 != 0)
            {
                propertyDict.Add(config.Effect5, config.EffectValueA5);
            }
 
            var index = 0;
            textBuilder.Length = 0;
            foreach (var key in propertyDict.Keys)
            {
                var propertyConfig = PlayerPropertyConfig.Get(key);
                textBuilder.Append(propertyConfig == null ? string.Empty : propertyConfig.Name);
                textBuilder.Append("  <color=#109d06>+");
                textBuilder.Append(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(count * propertyDict[key], propertyConfig == null ? 0 : propertyConfig.ISPercentage)));
                textBuilder.Append("</color>");
                index++;
                textBuilder.Append(index % 3 == 0 && index > 0 ? "\n" : "  ");
            }
            m_Property.text = textBuilder.ToString();
        }
    }
}