示例#1
0
    public void Assign(Stats.Info source, string text)
    {
        hasSource = true;
        current   = source;

        float statSize = 0f;

        statSize += transform.GetComponentInChildren <RectTransform>().sizeDelta.x;

        var bgSize = background.sizeDelta;

        bgSize.x += (statSize + spacing);

        gameObject.SetActive(true);

        image.sprite  = source.Icon;
        image.color   = source.Color;
        textMesh.text = text;

        RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, image.flexibleWidth + textMesh.preferredWidth + spacing);
    }
示例#2
0
    private bool HandleStat(int index, IAttributeHolder attributes, Id id, Stats.Info info)
    {
        if (attributes.Args.TryGetValue(id, out var baseValue, out var value))
        {
            if (value == 0)
            {
                infos[index].TextMesh.color = normal;
            }
            else if (value > 0)
            {
                infos[index].TextMesh.color = bonus;
            }
            else
            {
                infos[index].TextMesh.color = malus;
            }

            infos[index].Assign(info, $"{baseValue + value}");

            return(true);
        }

        return(false);
    }