少年修仙传客户端代码仓库
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
83
84
85
86
87
88
89
90
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
 
namespace vnxbqy.UI
{
    public class RealmPropertyCell : MonoBehaviour
    {
        [SerializeField] Text[] m_PropertyNames;
        [SerializeField] Text[] m_PropertyValues;
        [SerializeField] Image[] m_Signs;
 
        public void Display(int _realmLv, bool _compare = true)
        {
            RealmConfig _realmCfg = RealmConfig.Get(_realmLv);
            var _index = 0;
            for (int i = 0; i < m_PropertyNames.Length; i++)
            {
                m_PropertyNames[i].SetActive(i < _realmCfg.AddAttrType.Length);
                m_PropertyValues[i].SetActive(i < _realmCfg.AddAttrType.Length);
                if (m_Signs != null && m_Signs.Length > 0)
                {
                    m_Signs[i].SetActive(i < _realmCfg.AddAttrType.Length);
                }
                if (i < _realmCfg.AddAttrType.Length)
                {
                    var _propCfg = PlayerPropertyConfig.Get(_realmCfg.AddAttrType[i]);
                    if (_compare && _realmLv > PlayerDatas.Instance.baseData.realmLevel)
                    {
                        m_PropertyNames[i].text = StringUtility.Contact(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(_realmCfg.AddAttrNum[i], _propCfg.ISPercentage)),
                            _propCfg.ISPercentage == 1 ? "%" : string.Empty);
                        var _addValue = _realmCfg.AddAttrNum[i] - GetBeforeRealmPropertyValue(_realmLv, _realmCfg.AddAttrType[i]);
                        if (_addValue == 0)
                        {
                            m_PropertyValues[i].text = string.Empty;
                        }
                        else
                        {
                            m_PropertyValues[i].text = StringUtility.Contact("+", UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(_addValue, _propCfg.ISPercentage)),
                            _propCfg.ISPercentage == 1 ? "%" : string.Empty);
                        }
                    }
                    else
                    {
                        m_PropertyNames[i].text = _propCfg.Name;
                        m_PropertyValues[i].text = StringUtility.Contact(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(_realmCfg.AddAttrNum[i], _propCfg.ISPercentage)),
                            _propCfg.ISPercentage == 1 ? "%" : string.Empty);
                    }
                    _index++;
                }
            }
            _realmCfg = RealmConfig.Get(_realmLv + 1);
            if (_compare && _realmCfg != null && _realmLv == PlayerDatas.Instance.baseData.realmLevel)
            {
                for (int i = _index; i < m_PropertyNames.Length; i++)
                {
                    m_PropertyNames[i].SetActive(i < _realmCfg.AddAttrType.Length);
                    m_PropertyValues[i].SetActive(i < _realmCfg.AddAttrType.Length);
                    if (i < _realmCfg.AddAttrType.Length)
                    {
                        var _propCfg = PlayerPropertyConfig.Get(_realmCfg.AddAttrType[i]);
                        m_PropertyNames[i].text = _propCfg.Name;
                        m_PropertyValues[i].text = StringUtility.Contact(0, _propCfg.ISPercentage == 1 ? "%" : string.Empty);
                    }
                }
            }
        }
 
        public int GetBeforeRealmPropertyValue(int _realmLv, int _property)
        {
            RealmConfig _realmCfg = RealmConfig.Get(_realmLv - 1);
            if (_realmCfg == null)
            {
                return 0;
            }
            for (int i = 0; i < _realmCfg.AddAttrType.Length; i++)
            {
                if (_realmCfg.AddAttrType[i] == _property)
                {
                    return _realmCfg.AddAttrNum[i];
                }
            }
            return 0;
        }
    }
}