using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ItemPotion : Item { public readonly int Effect; public readonly PotionType Type; public readonly int Time; // How long does this potion last? We don't have any use for it. Just here to demonstrate the item system public ItemPotion(string name, string iconName, int pbasePrice,int effect, PotionType type, int time = -1, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) { Effect = effect; Type = type; Time = Type == PotionType.Healing ? -1 : time; } // This is used so we can identify a type purely through polymorphism. No hardcoding of types involved, nothing to see here! public override ItemType GetItemType() { return ItemType.Potion; } public override string GetStats() { return Time > 0 ? "Strength: " + Effect + "\tType: " + Type + "\tTime: " + Time : "Strength: " + Effect + "\tType: " + Type; } public override void Upgrade(float upgradeFactor) { // Potions can't be upgraded } public override int GetUpgradeCosts(float upgradeFactor) { return 0; } } [Serializable] public enum PotionType { Healing, Attack, Defense }