/// <summary>
        /// Gets the string to draw for a list item.
        /// </summary>
        /// <param name="x">The list item.</param>
        /// <returns>The string to draw for a list item.</returns>
        static string GetDrawString(CharacterTemplateInventoryItem x)
        {
            var t = ItemTemplateManager.Instance[x.ID];
            string item;

            if (t == null)
                item = "ID " + x;
            else
                item = t.ID + ". " + t.Name;

            var chance = string.Format("[{0:#,000.00}%] [{1} - {2}]", Math.Round(x.Chance.Percentage * 100, 2), x.Min, x.Max);

            return chance + " " + item;
        }
        /// <summary>
        /// Creates an instance of the <see cref="ItemEntity"/> from the template.
        /// </summary>
        /// <returns>The instance of the <see cref="ItemEntity"/>, or null if the creation chance failed.</returns>
        public static ItemEntity CreateInstance(this CharacterTemplateInventoryItem v)
        {
            if (!v.Chance.Test())
            {
                return(null);
            }

            var amount = (byte)_random.Next(v.Min, v.Max + 1);

            if (amount == 0)
            {
                return(null);
            }

            var instance = new ItemEntity(v.ItemTemplate, Vector2.Zero, amount);

            return(instance);
        }
예제 #3
0
        /// <summary>
        /// Provides the extra text for the <see cref="AdvancedPropertyDescriptor"/> for a
        /// <see cref="CharacterTemplateEquippedItem"/>.
        /// </summary>
        /// <param name="v">The value.</param>
        /// <returns>The extra text to display.</returns>
        static string ExtraTextProvider_CharacterTemplateInventoryItem(CharacterTemplateInventoryItem v)
        {
            var item = ItemTemplateManager.Instance[v.ID];
            if (item == null)
                return null;

            var chance = Math.Round(v.Chance.Percentage * 100f, 0) + "%";

            return "[" + chance + "] " + item.Name;
        }