UIItemSlot.Update C# (CSharp) Method

Update() public method

Keep an eye on the item and update the icon when it changes.
public Update ( ) : void
return void
    void Update()
    {
        InvGameItem i = observedItem;

        if (mItem != i)
        {
            mItem = i;

            InvBaseItem baseItem = (i != null) ? i.baseItem : null;

            if (label != null)
            {
                string itemName = (i != null) ? i.name : null;
                if (string.IsNullOrEmpty(mText)) mText = label.text;
                label.text = (itemName != null) ? itemName : mText;
            }

            if (icon != null)
            {
                if (baseItem == null || baseItem.iconAtlas == null)
                {
                    icon.enabled = false;
                }
                else
                {
                    icon.atlas = baseItem.iconAtlas;
                    icon.spriteName = baseItem.iconName;
                    icon.enabled = true;
                    icon.MakePixelPerfect();
                }
            }

            if (background != null)
            {
                background.color = (i != null) ? i.color : Color.white;
            }
        }
    }

Usage Example

コード例 #1
0
        /// <summary>
        /// Draw the wing slots.
        /// </summary>
        /// <param name="spriteBatch">drawing SpriteBatch</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            if (ShouldDrawSlots())
            {
                int   mapH      = 0;
                int   rX        = 0;
                int   rY        = 0;
                float origScale = Main.inventoryScale;

                Main.inventoryScale = 0.85f;

                if (Main.mapEnabled)
                {
                    if (!Main.mapFullscreen && Main.mapStyle == 1)
                    {
                        mapH = 256;
                    }

                    if ((mapH + 600) > Main.screenHeight)
                    {
                        mapH = Main.screenHeight - 600;
                    }
                }

                rX = Main.screenWidth - 92 - (47 * 2);
                rY = mapH + 174;

                if (Main.netMode == 1)
                {
                    rX -= 47;
                }

                EquipWingSlot.Position  = new Vector2(rX, rY);
                VanityWingSlot.Position = new Vector2(rX -= 47, rY);
                WingDyeSlot.Position    = new Vector2(rX -= 47, rY);

                VanityWingSlot.Draw(spriteBatch);
                EquipWingSlot.Draw(spriteBatch);
                WingDyeSlot.Draw(spriteBatch);

                Main.inventoryScale = origScale;

                EquipWingSlot.Update();
                VanityWingSlot.Update();
                WingDyeSlot.Update();

                UIUtils.UpdateInput();
            }
        }
All Usage Examples Of UIItemSlot::Update