예제 #1
0
        public virtual void RefreshSlot()
        {
            var titleTextComponent       = transform.Find("ItemTitle").gameObject.GetComponent <Text>();
            var iconComponent            = transform.Find("ItemIcon").gameObject.GetComponent <Image>();
            var descriptionTextComponent = transform.Find("ItemDescription").gameObject.GetComponent <Text>();
            var statsTextComponent       = transform.Find("ItemStats").gameObject.GetComponent <Text>();
            var quantityTextComponent    = transform.Find("ItemQuantity").gameObject.GetComponent <Text>();
            var qualityTextComponent     = transform.Find("ItemQuality").gameObject.GetComponent <Text>();
            var equippedImageObjet       = transform.Find("EquippedImage").gameObject;

            if (HasItem && itemInstance != null)
            {
                //Debug.Log(itemInstance.IsEquipped);
                equippedImageObjet.SetActive(itemInstance.IsEquipped);

                titleTextComponent.text       = itemInstance.ItemTemplate.ItemName;
                iconComponent.sprite          = itemInstance.ItemTemplate.Icon;
                descriptionTextComponent.text = itemInstance.ItemTemplate.ItemDescription;
                statsTextComponent.text       = itemInstance.GetStatsText("{2}:<b>{1}{0}</b>  ");
                quantityTextComponent.text    = itemInstance.Quantity > 1 ? "x" + itemInstance.Quantity.ToString() : String.Empty;
                qualityTextComponent.text     = itemInstance.Quality.ToString();
                var itemColor = Color.black;
                switch (itemInstance.Quality)
                {
                case ItemQuality.Weak:
                    itemColor = WeakItemColor;
                    break;

                case ItemQuality.Regular:
                    itemColor = RegularItemColor;
                    break;

                case ItemQuality.Exceptional:
                    itemColor = ExceptionalItemColor;
                    break;

                case ItemQuality.Rare:
                    itemColor = RareItemColor;
                    break;

                case ItemQuality.Legend:
                    itemColor = LegendItemColor;
                    break;
                }
                qualityTextComponent.color = itemColor;
            }
            else
            {
                titleTextComponent.text       = String.Empty;
                iconComponent.sprite          = null;
                descriptionTextComponent.text = String.Empty;
                statsTextComponent.text       = String.Empty;
                quantityTextComponent.text    = String.Empty;
                qualityTextComponent.text     = String.Empty;
                qualityTextComponent.color    = Color.black;
            }
        }
        internal void SetPanel(ItemInstance itemInstance)
        {
            if (itemInstance != null)
            {
                this.itemInstance = itemInstance;
                ItemImage.sprite  = itemInstance.ItemTemplate.Icon;
                //ItemImage.color = tempColor;

                var itemColor = Color.black;
                switch (itemInstance.Quality)
                {
                case ItemQuality.Weak:
                    itemColor = WeakItemColor;
                    break;

                case ItemQuality.Regular:
                    itemColor = RegularItemColor;
                    break;

                case ItemQuality.Exceptional:
                    itemColor = ExceptionalItemColor;
                    break;

                case ItemQuality.Rare:
                    itemColor = RareItemColor;
                    break;

                case ItemQuality.Legend:
                    itemColor = LegendItemColor;
                    break;
                }

                //TitleText.color = itemColor;
                QualityText.color = itemColor;

                TitleText.text    = itemInstance.ItemTemplate.ItemName;
                DescText.text     = itemInstance.ItemTemplate.ItemDescription;
                LongDescText.text = itemInstance.ItemTemplate.ItemLongDescription;
                QualityText.text  = itemInstance.GetQualityText();
                StatsText.text    = itemInstance.GetStatsText(" {2}:<b>{1}{0}</b> ");



                UnequipButton.gameObject.SetActive(itemInstance.IsEquippable());
                UnequipButton.interactable = itemInstance.IsEquipped;
            }
            else
            {
                UnequipButton.gameObject.SetActive(false);
                UnequipButton.interactable = false;
            }
        }