using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System.Linq; namespace Snxxz.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].gameObject.SetActive(i < _realmCfg.AddAttrType.Length); m_PropertyValues[i].gameObject.SetActive(i < _realmCfg.AddAttrType.Length); if (m_Signs != null && m_Signs.Length > 0) { m_Signs[i].gameObject.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].gameObject.SetActive(i < _realmCfg.AddAttrType.Length); m_PropertyValues[i].gameObject.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; } } }