少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-04 49d14c36c7a6ec949fc18c118896550b45bcbfba
System/Equip/EquipSuitPropertyBar.cs
@@ -12,100 +12,30 @@
    public class EquipSuitPropertyBar : MonoBehaviour
    {
        [SerializeField] Text m_Titile;
        [SerializeField] PropertyLine[] m_Properties;
        [SerializeField] Text[] m_Properties;
        public void Display(EquipSuitPropertyEntry entry)
        {
            switch (entry.type)
            {
                case EquipSuitType.TwoSuit:
                    m_Titile.text = "【2件】";
                    break;
                case EquipSuitType.FiveSuit:
                    m_Titile.text = "【5件】";
                    break;
                default:
                    break;
            }
            m_Titile.color = UIHelper.GetUIColor(entry.actived ? TextColType.Green : TextColType.Gray, true);
            var color = UIHelper.GetUIColor(entry.actived ? TextColType.Green : TextColType.Gray, true);
            m_Titile.color = color;
            for (var i = 0; i < m_Properties.Length; i++)
            {
                var behaviour = m_Properties[i];
                if (entry.actived && entry.currentStarLevel != entry.nextStarLevel)
                if (i < entry.properties.Count)
                {
                    if (i < entry.currentProperties.Count)
                    {
                        var propertyId = entry.currentProperties[i].x;
                        var currentValue = entry.currentProperties[i].y;
                        var nextValue = entry.nextProperties[i].y;
                        behaviour.Display(new Int3(propertyId, currentValue, nextValue), entry.nextStarLevel);
                    }
                    else
                    {
                        behaviour.Hide();
                    }
                    var property = entry.properties[i];
                    behaviour.gameObject.SetActive(true);
                    var config = PlayerPropertyConfig.Get(property.x);
                    behaviour.text = string.Format("{0} +{1}", config.Name, PlayerPropertyConfig.GetPropertyDescription(property.x, property.y));
                }
                else
                {
                    if (i < entry.currentProperties.Count)
                    {
                        behaviour.Display(entry.currentProperties[i], entry.actived);
                    }
                    else
                    {
                        behaviour.Hide();
                    }
                    behaviour.gameObject.SetActive(false);
                }
                behaviour.color = color;
            }
        }
        [System.Serializable]
        public class PropertyLine
        {
            public RectTransform container;
            public Text current;
            public Image arrow;
            public Text next;
            public void Display(Int3 property, int nextLevel)
            {
                container.gameObject.SetActive(true);
                var config = PlayerPropertyConfig.Get(property.x);
                var isPercentage = config.ISPercentage == 1;
                var valueDescription = isPercentage ? StringUtility.Contact(Mathf.RoundToInt(property.y * 0.01f), "%") : property.y.ToString();
                current.text = string.Format("{0} +{1}", config.Name, valueDescription);
                current.color = UIHelper.GetUIColor(TextColType.Green, true);
                arrow.gameObject.SetActive(true);
                valueDescription = isPercentage ? StringUtility.Contact(Mathf.RoundToInt(property.z * 0.01f), "%") : property.z.ToString();
                next.text = string.Format("{0}星 +{1}", nextLevel, valueDescription);
                next.color = UIHelper.GetUIColor(TextColType.Gray, true);
            }
            public void Display(Int2 property, bool active)
            {
                container.gameObject.SetActive(true);
                var config = PlayerPropertyConfig.Get(property.x);
                var isPercentage = config.ISPercentage == 1;
                var valueDescription = isPercentage ? StringUtility.Contact(Mathf.RoundToInt(property.y * 0.01f), "%") : property.y.ToString();
                current.text = string.Format("{0} +{1}", config.Name, valueDescription);
                arrow.gameObject.SetActive(true);
                next.text = string.Empty;
                current.color = UIHelper.GetUIColor(active ? TextColType.Green : TextColType.Gray, true);
            }
            public void Hide()
            {
                container.gameObject.SetActive(false);
            }
        }
    }