fixed instance of object is null error when buying items in shop
This commit is contained in:
parent
ccb25d4335
commit
d3387a88c9
1 changed files with 17 additions and 13 deletions
|
|
@ -30,12 +30,15 @@ public class ShopSlot : ItemStorageSlot {
|
|||
* Gets called when the Shop Slot is clicked
|
||||
*/
|
||||
public override void UseItem() {
|
||||
if(Item) {
|
||||
if(_playerController.Money >= Item.cost) {
|
||||
_inventory.AddItem(Item, 1);
|
||||
_shop.RemoveItem(Item, 1);
|
||||
if(Item) {
|
||||
_playerController.ChangeMoney(-Item.cost);
|
||||
|
||||
Debug.Log("Buying Item: " + Item.displayName);
|
||||
}
|
||||
} else {
|
||||
Debug.Log("Not enough money to buy item.");
|
||||
}
|
||||
|
|
@ -43,4 +46,5 @@ public class ShopSlot : ItemStorageSlot {
|
|||
_shop.onItemChangedCallback?.Invoke();
|
||||
_inventory.onItemChangedCallback?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue