using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; /// /// This item factory uses all specified properties to procedurally generate a given amount of items. In this case, potion /// [CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor public class ProceduralPotionFactory : ItemFactory { public ItemRarity Rarity; public int EffectMin; public int EffectMax; public int PriceMin; public int PriceMax; public PotionPrototype[] Items; public int Amount; public override void PopulateModel(ShopModel model) { for (int i = 0; i < Amount; i++) { var item = Items[Random.Range(0, Items.Length)]; model.inventory.AddItem(new ItemPotion(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),item.EffectTime,item.Type,Random.Range(EffectMin,EffectMax) + item.Bonus + 3,item.Description, Rarity)); } } } [Serializable] public struct PotionPrototype { public Sprite Sprite; public string Name; public string Description; public int Bonus; public PotionType Type; public int EffectTime; }