Esempio n. 1
0
        protected IEnumerator DelayTooltip(float delay)
        {
            float time = 0.0f;

            yield return(true);

            while (time < delay)
            {
                time += Time.deltaTime;
                yield return(true);
            }
            if (InventoryManager.UI.tooltip != null && ObservedItem != null)
            {
                InventoryManager.UI.tooltip.Show(UnityTools.ColorString(ObservedItem.DisplayName, ObservedItem.Rarity.Color), ObservedItem.Description, ObservedItem.Icon, ObservedItem.GetPropertyInfo());
                if (InventoryManager.UI.sellPriceTooltip != null && ObservedItem.IsSellable && ObservedItem.SellPrice > 0)
                {
                    InventoryManager.UI.sellPriceTooltip.RemoveItems();
                    Currency currency = Instantiate(ObservedItem.SellCurrency);
                    currency.Stack = ObservedItem.SellPrice * ObservedItem.Stack;

                    InventoryManager.UI.sellPriceTooltip.StackOrAdd(currency);
                    InventoryManager.UI.sellPriceTooltip.Show();
                }
            }
        }
        private IEnumerator CraftItem(Item item)
        {
            this.m_ProgressDuration = item.CraftingDuration;
            this.m_ProgressInitTime = Time.time;
            yield return(new WaitForSeconds(item.CraftingDuration));

            Item craftedItem = Instantiate(item);

            craftedItem.PropertyPercentRange = item.PropertyPercentRange;
            craftedItem.RandomizeProperties();
            craftedItem.Stack = 1;
            if (this.m_ResultStorageContainer.StackOrAdd(craftedItem))
            {
                for (int i = 0; i < item.ingredients.Count; i++)
                {
                    this.m_RequiredIngredientsContainer.RemoveItem(item.ingredients[i].item, item.ingredients[i].amount);
                }
                InventoryManager.Notifications.craftedItem.Show(UnityTools.ColorString(craftedItem.Name, craftedItem.Rarity.Color));
                ExecuteEvent <ITriggerCraftItem>(Execute, craftedItem);
            }
            else
            {
                InventoryManager.Notifications.containerFull.Show(this.m_ResultStorageContainer.Name);
                ExecuteEvent <ITriggerFailedToCraftItem>(Execute, item, FailureCause.ContainerFull);
                StopCrafting(item);
            }
        }
 public override void Repaint(Item item)
 {
     if (this.m_ItemName != null)
     {
         //Updates the text with item name and rarity color. If this slot is empty, sets the text to empty.
         this.m_ItemName.text = (item != null ? (this.m_UseRarityColor ? UnityTools.ColorString(item.DisplayName, item.Rarity.Color) : item.DisplayName) : string.Empty);
     }
 }
Esempio n. 4
0
        public List <KeyValuePair <string, string> > GetPropertyInfo()
        {
            List <KeyValuePair <string, string> > propertyInfo = new List <KeyValuePair <string, string> >();

            foreach (ObjectProperty property in properties)
            {
                if (property.show)
                {
                    propertyInfo.Add(new KeyValuePair <string, string>(UnityTools.ColorString(property.Name, property.color), FormatPropertyValue(property)));
                }
            }
            return(propertyInfo);
        }
        private IEnumerator CraftItem(Item item)
        {
            this.m_ProgressDuration = item.CraftingDuration;
            this.m_ProgressInitTime = Time.time;
            yield return(new WaitForSeconds(item.CraftingDuration));

            if (item.UseCraftingSkill)
            {
                ItemContainer skills = WidgetUtility.Find <ItemContainer>(item.SkillWindow);
                Skill         skill  = (Skill)skills.GetItems(item.CraftingSkill.Id).FirstOrDefault();
                if (skill == null)
                {
                    Debug.LogWarning("Skill not found in " + item.SkillWindow + ".");
                }
                if (!skill.CheckSkill())
                {
                    InventoryManager.Notifications.failedToCraft.Show(item.DisplayName);
                    if (item.RemoveIngredientsWhenFailed)
                    {
                        for (int i = 0; i < item.ingredients.Count; i++)
                        {
                            this.m_RequiredIngredientsContainer.RemoveItem(item.ingredients[i].item, item.ingredients[i].amount);
                        }
                    }
                    yield break;
                }
            }

            Item craftedItem = Instantiate(item);

            craftedItem.Stack = 1;
            craftedItem.CraftingModifier.Modify(craftedItem);



            if (this.m_ResultStorageContainer.StackOrAdd(craftedItem))
            {
                for (int i = 0; i < item.ingredients.Count; i++)
                {
                    this.m_RequiredIngredientsContainer.RemoveItem(item.ingredients[i].item, item.ingredients[i].amount);
                }
                InventoryManager.Notifications.craftedItem.Show(UnityTools.ColorString(craftedItem.Name, craftedItem.Rarity.Color));
                ExecuteEvent <ITriggerCraftItem>(Execute, craftedItem);
            }
            else
            {
                InventoryManager.Notifications.containerFull.Show(this.m_ResultStorageContainer.Name);
                ExecuteEvent <ITriggerFailedToCraftItem>(Execute, item, FailureCause.ContainerFull);
                StopCrafting(item);
            }
        }
Esempio n. 6
0
        private string FormatPropertyValue(ObjectProperty property)
        {
            string propertyValue = string.Empty;

            if (property.SerializedType == typeof(Vector2))
            {
                propertyValue = property.vector2Value.x + "-" + property.vector2Value.y;
            }
            else
            {
                propertyValue  = ((UnityTools.IsNumeric(property.GetValue()) && System.Convert.ToSingle(property.GetValue()) > 0f) ? "+" : "-");
                propertyValue += (UnityTools.IsNumeric(property.GetValue()) ? Mathf.Abs(System.Convert.ToSingle(property.GetValue())) : property.GetValue()).ToString();
            }
            propertyValue = UnityTools.ColorString(propertyValue, property.color);
            return(propertyValue);
        }
Esempio n. 7
0
        protected IEnumerator DelayTooltip(float delay)
        {
            float time = 0.0f;

            yield return(true);

            while (time < delay)
            {
                time += Time.deltaTime;
                yield return(true);
            }
            if (InventoryManager.UI.tooltip != null && ObservedItem != null)
            {
                InventoryManager.UI.tooltip.Show(UnityTools.ColorString(ObservedItem.Name, ObservedItem.Rarity.Color), ObservedItem.Description, ObservedItem.Icon, ObservedItem.GetPropertyInfo());
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Repaint slot visuals with item information
        /// </summary>
        public virtual void Repaint()
        {
            if (this.m_ItemName != null)
            {
                //Updates the text with item name and rarity color. If this slot is empty, sets the text to empty.
                this.m_ItemName.text = (!IsEmpty ? (this.m_UseRarityColor?UnityTools.ColorString(ObservedItem.DisplayName, ObservedItem.Rarity.Color):ObservedItem.DisplayName) : string.Empty);
            }

            if (this.m_Ícon != null)
            {
                if (!IsEmpty)
                {
                    //Updates the icon and enables it.
                    this.m_Ícon.overrideSprite = ObservedItem.Icon;
                    this.m_Ícon.enabled        = true;
                }
                else
                {
                    //If there is no item in this slot, disable icon
                    this.m_Ícon.enabled = false;
                }
            }

            if (this.m_Stack != null)
            {
                if (!IsEmpty && ObservedItem.MaxStack > 1)
                {
                    //Updates the stack and enables it.
                    this.m_Stack.text    = ObservedItem.Stack.ToString();
                    this.m_Stack.enabled = true;
                }
                else
                {
                    //If there is no item in this slot, disable stack field
                    this.m_Stack.enabled = false;
                }
            }
        }
 public void Show(Item item)
 {
     Show(UnityTools.ColorString(item.DisplayName, item.Rarity.Color), item.Description, item.Icon, item.GetPropertyInfo());
 }
 protected virtual void NotifyItemCrafted(Item item)
 {
     InventoryManager.Notifications.craftedItem.Show(UnityTools.ColorString(item.Name, item.Rarity.Color));
     ExecuteEvent <ITriggerCraftItem>(Execute, item);
 }