private static void EntityParser(EntityCard.Data data, object obj)
    {
        Entity entity = obj as Entity;

        data.Name = (data.Name == entity.Name || !data.HasData(EntityCard.DataTypes.Name)) ? entity.Name : "Various";

        data.MinCurrentHealth = (data.MinCurrentHealth > entity.Health || !data.HasData(EntityCard.DataTypes.MinCurrentHealth)) ? (int)entity.Health : data.MinCurrentHealth;
        data.MaxCurrentHealth = (data.MaxCurrentHealth < entity.Health || !data.HasData(EntityCard.DataTypes.MaxCurrentHealth)) ? (int)entity.Health : data.MaxCurrentHealth;

        data.MinMaxHealth = (data.MinMaxHealth > entity.MaxHealth || !data.HasData(EntityCard.DataTypes.MinMaxHealth)) ? entity.MaxHealth : data.MinMaxHealth;
        data.MaxMaxHealth = (data.MaxMaxHealth < entity.MaxHealth || !data.HasData(EntityCard.DataTypes.MaxMaxHealth)) ? entity.MaxHealth : data.MaxMaxHealth;
    }
예제 #2
0
    public void Initialize(EntityCard.Data data)
    {
        if (data.HasData(FirstValue) && data.HasData(SecondValue) && data.HasData(RelativeValue))
        {
            Enable();

            float firstValue  = data.GetData <int>(FirstValue);
            float secondValue = data.GetData <int>(SecondValue);
            float relative    = data.GetData <int>(RelativeValue);

            MinValue = Mathf.Min(firstValue, secondValue);
            MaxValue = Mathf.Max(firstValue, secondValue);

            _bottomSlider.fillAmount = MaxValue / relative;
            _topSlider.fillAmount    = MinValue / relative;

            if (_textElement != null)
            {
                if (MinValue == relative)
                {
                    _textElement.text = string.Format("{0}", relative);
                }
                else
                {
                    _textElement.text = string.Format("{0} / {1} / {2}", MinValue, MaxValue, relative);
                }
            }
        }
        else if (_disableIfEmpty)
        {
            Disable();
        }

        if (OnReceviedData != null)
        {
            OnReceviedData.Invoke(data);
        }
    }
    public void Initialize(EntityCard.Data data)
    {
        if (data.HasData(DataType))
        {
            Enable();

            InitializeData(data);
        }
        else if (_disableIfEmpty)
        {
            Disable();
        }

        if (OnReceviedData != null)
        {
            OnReceviedData.Invoke(data);
        }
    }