using System.Collections; using System.Collections.Generic; using UnityEngine; public class ItemArmor : Item { public int Defense { get; private set; } public int Block { get; private set; } private readonly int startPrice; // Represents the price this is worth without upgrades - for price calculation public ItemArmor(string name, string iconName, int pbasePrice,int pDefense, int pBlock, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) { Block = pBlock; Defense = pDefense; startPrice = basePrice; } // 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.Armor; } public override string GetStats() { return "Defense: " + Defense + "\tBlock: " + Block; } public override void Upgrade(float upgradeFactor) { Block = (int) (Block * upgradeFactor); // Don't wanna randomise upgrades for now, to be honest Defense = (int) (Defense * upgradeFactor); // We increase value, but only by half as much as the upgrade improved stats. No one wants to buy a bad item upgraded to be passable. Cost to do so is higher by as much as the upgrade shop charges extra basePrice += (int)(GetUpgradeCosts(upgradeFactor) * 0.5); // The goal is to make upgrading an endless money sink, and incentivise buying better base items } public override int GetUpgradeCosts(float upgradeFactor) { return (int) (((basePrice * upgradeFactor) - startPrice)); } }