diff --git a/Assets/Resources/UpgradeShop.asset b/Assets/Resources/UpgradeShop.asset index 963476a..2e92180 100644 --- a/Assets/Resources/UpgradeShop.asset +++ b/Assets/Resources/UpgradeShop.asset @@ -12,5 +12,5 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3145dd14dac0cf84a909862b61ec2893, type: 3} m_Name: UpgradeShop m_EditorClassIdentifier: - PriceModifier: 5 + PriceModifier: 3 UpgradeFactor: 1.5 diff --git a/Assets/Scripts/Shop/Model/ItemArmor.cs b/Assets/Scripts/Shop/Model/ItemArmor.cs index 7864e0f..c947015 100644 --- a/Assets/Scripts/Shop/Model/ItemArmor.cs +++ b/Assets/Scripts/Shop/Model/ItemArmor.cs @@ -7,11 +7,15 @@ 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! @@ -35,6 +39,6 @@ public class ItemArmor : Item public override int GetUpgradeCosts(float upgradeFactor) { - return (int) (((basePrice * upgradeFactor) - basePrice)); + return (int) (((basePrice * upgradeFactor) - startPrice)); } } diff --git a/Assets/Scripts/Shop/Model/ItemPotion.cs b/Assets/Scripts/Shop/Model/ItemPotion.cs index 946d921..c290fad 100644 --- a/Assets/Scripts/Shop/Model/ItemPotion.cs +++ b/Assets/Scripts/Shop/Model/ItemPotion.cs @@ -8,6 +8,7 @@ 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; @@ -30,7 +31,7 @@ public class ItemPotion : Item public override void Upgrade(float upgradeFactor) { - throw new NotImplementedException(); + // Potions can't be upgraded } public override int GetUpgradeCosts(float upgradeFactor) diff --git a/Assets/Scripts/Shop/Model/ItemWeapon.cs b/Assets/Scripts/Shop/Model/ItemWeapon.cs index d3a58f1..8520af0 100644 --- a/Assets/Scripts/Shop/Model/ItemWeapon.cs +++ b/Assets/Scripts/Shop/Model/ItemWeapon.cs @@ -4,12 +4,15 @@ using UnityEngine; public class ItemWeapon : Item { - public readonly int Attack; - public readonly int Damage; + public int Attack { get; private set; } + public int Damage { get; private set; } + + private readonly int startPrice; // Represents the price this is worth without upgrades - for price calculation public ItemWeapon(string name, string iconName, int pbasePrice,int pAttack, int pDamage, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) { Attack = pAttack; Damage = pDamage; + startPrice = basePrice; } public override ItemType GetItemType() @@ -24,11 +27,14 @@ public class ItemWeapon : Item public override void Upgrade(float upgradeFactor) { - throw new System.NotImplementedException(); + Attack = (int) (Attack * upgradeFactor); // Don't wanna randomise upgrades for now, to be honest + Damage = (int) (Damage * 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 0; + return (int) (((basePrice * upgradeFactor) - startPrice)); } }