Example #1
0
    public void SetFrame(ItemInstance i)
    {
        if (!i.isSetup() || i.GetItem().icon == null)
        {
            icon.sprite = iconOriginal;
        }
        else
        {
            icon.sprite = i.GetItem().icon;
        }
        if (i.isSetup())
        {
            frame.color = i.GetHalfQualityColor();
            int netPrimary = i.GetNetPrimary();
            primaryStat.sizeDelta = new Vector2(Mathf.Max(1, Mathf.Abs(netPrimary)) * originalWidth, primaryStat.sizeDelta.y);
            if (netPrimary > 0)
            {
                primaryImage.color = Color.green;
            }
            else if (netPrimary < 0)
            {
                primaryImage.color = Color.red;
            }
            else
            {
                primaryImage.color = Color.white;
            }

            int netSecondary = i.GetNetSecondary();
            secondaryStat.sizeDelta = new Vector2(Mathf.Max(1, Mathf.Abs(netSecondary)) * originalWidth, secondaryStat.sizeDelta.y);
            if (netSecondary > 0)
            {
                secondaryImage.color = Color.green;
            }
            else if (netSecondary < 0)
            {
                secondaryImage.color = Color.red;
            }
            else
            {
                secondaryImage.color = Color.white;
            }

            itemName.text  = i.GetFullName();
            itemName.color = i.GetLightQualityColor();
        }
    }