Browse Source

Add weapon upgrades and more money-sinky upgrade function

Devin Braune 5 years ago
parent
commit
41d6eada5f
  1. 2
      Assets/Resources/UpgradeShop.asset
  2. 6
      Assets/Scripts/Shop/Model/ItemArmor.cs
  3. 3
      Assets/Scripts/Shop/Model/ItemPotion.cs
  4. 14
      Assets/Scripts/Shop/Model/ItemWeapon.cs

2
Assets/Resources/UpgradeShop.asset

@ -12,5 +12,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3145dd14dac0cf84a909862b61ec2893, type: 3} m_Script: {fileID: 11500000, guid: 3145dd14dac0cf84a909862b61ec2893, type: 3}
m_Name: UpgradeShop m_Name: UpgradeShop
m_EditorClassIdentifier: m_EditorClassIdentifier:
PriceModifier: 5 PriceModifier: 3
UpgradeFactor: 1.5 UpgradeFactor: 1.5

6
Assets/Scripts/Shop/Model/ItemArmor.cs

@ -8,10 +8,14 @@ public class ItemArmor : Item
public int Block { 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) 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; Block = pBlock;
Defense = pDefense; 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! // 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) public override int GetUpgradeCosts(float upgradeFactor)
{ {
return (int) (((basePrice * upgradeFactor) - basePrice)); return (int) (((basePrice * upgradeFactor) - startPrice));
} }
} }

3
Assets/Scripts/Shop/Model/ItemPotion.cs

@ -8,6 +8,7 @@ public class ItemPotion : Item
public readonly int Effect; public readonly int Effect;
public readonly PotionType Type; 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 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) 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; Effect = effect;
@ -30,7 +31,7 @@ public class ItemPotion : Item
public override void Upgrade(float upgradeFactor) public override void Upgrade(float upgradeFactor)
{ {
throw new NotImplementedException(); // Potions can't be upgraded
} }
public override int GetUpgradeCosts(float upgradeFactor) public override int GetUpgradeCosts(float upgradeFactor)

14
Assets/Scripts/Shop/Model/ItemWeapon.cs

@ -4,12 +4,15 @@ using UnityEngine;
public class ItemWeapon : Item public class ItemWeapon : Item
{ {
public readonly int Attack; public int Attack { get; private set; }
public readonly int Damage; 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) 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; Attack = pAttack;
Damage = pDamage; Damage = pDamage;
startPrice = basePrice;
} }
public override ItemType GetItemType() public override ItemType GetItemType()
@ -24,11 +27,14 @@ public class ItemWeapon : Item
public override void Upgrade(float upgradeFactor) 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) public override int GetUpgradeCosts(float upgradeFactor)
{ {
return 0; return (int) (((basePrice * upgradeFactor) - startPrice));
} }
} }

Loading…
Cancel
Save