Items adjusted prices
fixed some Tile sheeesh selling overflowing Items in Inventory (over 999)
This commit is contained in:
parent
79e86e343c
commit
cdd8ae7441
21 changed files with 106 additions and 84 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Inventory : ItemStorage {
|
||||
|
|
@ -15,17 +16,28 @@ public class Inventory : ItemStorage {
|
|||
|
||||
#endregion
|
||||
|
||||
private const int _InventorySpace = 28;
|
||||
private const int InventorySpace = 28;
|
||||
private const int MaxItemStack = 999;
|
||||
|
||||
/**
|
||||
* Adds the specified amount of items to the Inventory
|
||||
*/
|
||||
public override void AddItem(Item item, int amount) {
|
||||
if(items.Count >= _InventorySpace) {
|
||||
if(items.Count >= InventorySpace) {
|
||||
Debug.Log("Not enough inventory space!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Sell overflowing Items
|
||||
if(items.ContainsKey(item) && items[item] + amount >= MaxItemStack) {
|
||||
SellItem(item, amount - (MaxItemStack - items[item]));
|
||||
amount = MaxItemStack - items[item];
|
||||
}
|
||||
base.AddItem(item, amount);
|
||||
}
|
||||
|
||||
public void SellItem(Item item, int amount) {
|
||||
PlayerController.instance.ChangeMoney(item.SellPrice);
|
||||
Shop.instance.AddItem(item, amount);
|
||||
RemoveItem(item, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue