movement and dialogue system
This commit is contained in:
parent
977e666577
commit
1590b5faa6
123 changed files with 62825 additions and 355 deletions
60
Assets/Scripts/Inventory/InventoryManager.cs
Normal file
60
Assets/Scripts/Inventory/InventoryManager.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
public class InventoryManager : MonoBehaviour
|
||||
{
|
||||
public int maxCapacity;
|
||||
public int currentlyStored;
|
||||
public Dictionary<Item, int> storedItems = new();
|
||||
public Item[] itemList;
|
||||
public int money;
|
||||
|
||||
public bool RemoveMoney(int change)
|
||||
{
|
||||
if (money - change >= 0)
|
||||
{
|
||||
money -= change;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void AddMoney(int change)
|
||||
{
|
||||
money += change;
|
||||
}
|
||||
|
||||
public int AddItem(Item itemToAdd, int amount = 1)
|
||||
{
|
||||
if (currentlyStored < maxCapacity)
|
||||
{
|
||||
if (!storedItems.ContainsKey(itemToAdd))
|
||||
{
|
||||
storedItems[itemToAdd] = 0;
|
||||
}
|
||||
if (currentlyStored + amount <= maxCapacity)
|
||||
{
|
||||
storedItems[itemToAdd] += amount;
|
||||
currentlyStored += amount;
|
||||
return 0;
|
||||
}
|
||||
//return the amount that wasn't able to be stored.
|
||||
int stored = maxCapacity - currentlyStored;
|
||||
storedItems[itemToAdd] += stored;
|
||||
currentlyStored += stored;
|
||||
amount -= stored;
|
||||
return amount;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool RemoveItem(Item itemToRemove, int amount = 1)
|
||||
{
|
||||
if (!storedItems.ContainsKey(itemToRemove) || storedItems[itemToRemove] < amount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
storedItems[itemToRemove] -= amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue