added cost amount to items
added Shop UI added Shop.cs * you now can buy items and you lose the cost when bought * shop is scrollable added comments in Inventory.cs, InventorySlot.cs, InventoryUI.cs now showing description when hovering over items in shop or inventory
This commit is contained in:
parent
c9416181fc
commit
ce1f6ed389
30 changed files with 4726 additions and 64 deletions
|
|
@ -1,5 +1,3 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -20,8 +18,11 @@ public class Inventory : MonoBehaviour {
|
|||
|
||||
public Dictionary<Item, int> items;
|
||||
public Item[] startItems;
|
||||
public const int inventorySpace = 28;
|
||||
public const int InventorySpace = 28;
|
||||
|
||||
/**
|
||||
* Methods can be added to this and they will get called every time onItemChangedCallback gets Invoked
|
||||
*/
|
||||
public delegate void OnItemChanged();
|
||||
public OnItemChanged onItemChangedCallback;
|
||||
|
||||
|
|
@ -32,8 +33,11 @@ public class Inventory : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified amount of items to the Inventory
|
||||
*/
|
||||
public void AddItem(Item item, int amount) {
|
||||
if(items.Count >= inventorySpace) {
|
||||
if(items.Count >= InventorySpace) {
|
||||
Debug.Log("Not enough inventory space!");
|
||||
return;
|
||||
}
|
||||
|
|
@ -46,12 +50,15 @@ public class Inventory : MonoBehaviour {
|
|||
|
||||
onItemChangedCallback?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified amount of items in the Inventory
|
||||
*/
|
||||
public void RemoveItem(Item item, int amount) {
|
||||
if(items[item] <= 0) {
|
||||
items.Remove(item);
|
||||
} else {
|
||||
items.Add(item, -amount);
|
||||
items[item] -= amount;
|
||||
}
|
||||
|
||||
onItemChangedCallback?.Invoke();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue