Example #1
0
        public void OnSlotAssign(UIItemSlot slot)
        {
            if (this.m_Target == null && slot.GetItemInfo() != null)
            {
                return;
            }

            this.m_Target.canvasRenderer.SetColor(UIItemQualityColor.GetColor(slot.GetItemInfo().Quality));
        }
Example #2
0
        /// <summary>
        /// Prepares the tooltip with the specified item info.
        /// </summary>
        /// <param name="itemInfo">Item info.</param>
        public static void PrepareTooltip(UIItemInfo itemInfo)
        {
            if (itemInfo == null)
            {
                return;
            }

            // Set the tooltip width
            if (UITooltipManager.Instance != null)
            {
                UITooltip.SetWidth(UITooltipManager.Instance.itemTooltipWidth);
            }

            // Set the title and description
            UITooltip.AddTitle("<color=#" + UIItemQualityColor.GetHexColor(itemInfo.Quality) + ">" + itemInfo.Name + "</color>");

            // Spacer
            UITooltip.AddSpacer();

            // Item types
            UITooltip.AddLineColumn(itemInfo.Type, "ItemAttribute");
            UITooltip.AddLineColumn(itemInfo.Subtype, "ItemAttribute");

            if (itemInfo.ItemType == 1)
            {
                UITooltip.AddLineColumn(itemInfo.Damage.ToString() + " Damage", "ItemAttribute");
                UITooltip.AddLineColumn(itemInfo.AttackSpeed.ToString("0.0") + " Attack speed", "ItemAttribute");

                UITooltip.AddLine("(" + ((float)itemInfo.Damage / itemInfo.AttackSpeed).ToString("0.0") + " damage per second)", "ItemAttribute");
            }
            else
            {
                UITooltip.AddLineColumn(itemInfo.Armor.ToString() + " Armor", "ItemAttribute");
                UITooltip.AddLineColumn(itemInfo.Block.ToString() + " Block", "ItemAttribute");
            }

            UITooltip.AddSpacer();

            UITooltip.AddLine("+" + itemInfo.Stamina.ToString() + " Stamina", "ItemStat");
            UITooltip.AddLine("+" + itemInfo.Strength.ToString() + " Strength", "ItemStat");

            UITooltip.AddSpacer();

            UITooltip.AddLine("Durability " + itemInfo.Durability + "/" + itemInfo.Durability, "ItemAttribute");

            if (itemInfo.RequiredLevel > 0)
            {
                UITooltip.AddLine("Requires Level " + itemInfo.RequiredLevel, "ItemAttribute");
            }

            // Set the item description if not empty
            if (!string.IsNullOrEmpty(itemInfo.Description))
            {
                UITooltip.AddSpacer();
                UITooltip.AddLine(itemInfo.Description, "ItemDescription");
            }
        }