27 lines
688 B
C#
27 lines
688 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
[Serializable]
|
|
public class PlayerInventory
|
|
{
|
|
[SerializeField] private List<InventoryItem> inventoryItemList = new();
|
|
|
|
public void AddItem(Item item, int count)
|
|
{
|
|
var existingItem = inventoryItemList.Find(i => i.Item.name == item.name);
|
|
|
|
if (existingItem != null)
|
|
{
|
|
existingItem.Count += count;
|
|
}
|
|
else
|
|
{
|
|
inventoryItemList.Add(new InventoryItem(item, count));
|
|
}
|
|
}
|
|
}
|
|
} |