Fishing + Deselected stuff better
This commit is contained in:
parent
1b0f890b0b
commit
147af498c3
2 changed files with 9 additions and 11 deletions
|
|
@ -113,7 +113,7 @@ public class FishingController : MonoBehaviour {
|
||||||
Debug.Log("Tried to catch!");
|
Debug.Log("Tried to catch!");
|
||||||
if (_fishingTime <= _maxTime) {
|
if (_fishingTime <= _maxTime) {
|
||||||
Debug.Log("Caught!");
|
Debug.Log("Caught!");
|
||||||
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime/2)), 1));
|
_iv.AddItem(_ic.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime/2)), 1));
|
||||||
ResetFishing();
|
ResetFishing();
|
||||||
} else {
|
} else {
|
||||||
Debug.Log("Failed to catch!");
|
Debug.Log("Failed to catch!");
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ public class Inventory : ItemStorage {
|
||||||
public static Inventory instance;
|
public static Inventory instance;
|
||||||
|
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
if(instance != null) {
|
if (instance != null) {
|
||||||
Debug.LogWarning("More than one instance of Inventory found");
|
Debug.LogWarning("More than one instance of Inventory found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15,31 +15,29 @@ public class Inventory : ItemStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private const int InventorySpace = 28;
|
private const int InventorySpace = 28;
|
||||||
private const int MaxItemStack = 999;
|
private const int MaxItemStack = 999;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified amount of items to the Inventory
|
* Adds the specified amount of items to the Inventory
|
||||||
*/
|
*/
|
||||||
public override void AddItem(Item item, int amount) {
|
public override void AddItem(Item item, int amount) {
|
||||||
if(items.Count >= InventorySpace) {
|
if (items.Count >= InventorySpace) {
|
||||||
Debug.Log("Not enough inventory space!");
|
Debug.Log("Not enough inventory space!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Sell overflowing Items
|
// Sell overflowing Items
|
||||||
if(items.ContainsKey(item) && items[item] + amount >= MaxItemStack) {
|
if (items.ContainsKey(item) && items[item] + amount >= MaxItemStack) {
|
||||||
SellItem(item, amount - (MaxItemStack - items[item]));
|
SellItem(item, amount - (MaxItemStack - items[item]));
|
||||||
amount = MaxItemStack - items[item];
|
amount = MaxItemStack - items[item];
|
||||||
}
|
}
|
||||||
base.AddItem(item, amount);
|
base.AddItem(item, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RemoveItem(Item item, int amount)
|
public override void RemoveItem(Item item, int amount) {
|
||||||
{
|
|
||||||
base.RemoveItem(item, amount);
|
base.RemoveItem(item, amount);
|
||||||
if (!items.ContainsKey(item))
|
if (!items.ContainsKey(item) && PlayerController.instance.GetSelectedItem() == item) {
|
||||||
{
|
|
||||||
PlayerController.instance.DeselectItem();
|
PlayerController.instance.DeselectItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,4 +47,4 @@ public class Inventory : ItemStorage {
|
||||||
Shop.instance.AddItem(item, amount);
|
Shop.instance.AddItem(item, amount);
|
||||||
RemoveItem(item, amount);
|
RemoveItem(item, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue