46 lines
971 B
C#
46 lines
971 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Inventory : MonoBehaviour
|
|
{
|
|
private List<Item> itemList;
|
|
private int maxItems = 7;
|
|
|
|
public Inventory()
|
|
{
|
|
itemList = new List<Item>();
|
|
AddItem(new Item { itemType = Item.ItemType.BluePotion, amount = 1 });
|
|
}
|
|
|
|
public void AddItem(Item item)
|
|
{
|
|
if (itemList.Count < maxItems)
|
|
{
|
|
itemList.Add(item);
|
|
Debug.Log(itemList);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Ekwipunek jest pe³ny! Nie mo¿na dodaæ wiêcej przedmiotów.");
|
|
}
|
|
}
|
|
|
|
public List<Item> GetItemList()
|
|
{
|
|
return itemList;
|
|
}
|
|
|
|
public void RemoveItem(Item item)
|
|
{
|
|
var FoundItem = itemList.Find(x => x == item);
|
|
if (FoundItem.amount > 1)
|
|
{
|
|
FoundItem.RemoveAmount(1);
|
|
}
|
|
else
|
|
{
|
|
itemList.Remove(item);
|
|
}
|
|
}
|
|
} |