UnityGameProjectsCode / InTheDarkGame / Player / ItemInventory.cs
ItemInventory.cs
Raw
using System.Collections.Generic;
using UnityEngine;

public class ItemInventory : MonoBehaviour
{
    private List<Key> pickedUpKeys = new List<Key>();
    private BarrierTool barrier;

    private void Awake()
    {
        barrier = GetComponent<BarrierTool>();
    }

    public void PickUpKey(Key newKey)
    {
        pickedUpKeys.Add(newKey);
    }

    public void EnableBarrier()
    {
        barrier.enabled = true;
    }

    public bool CheckForKey(int doorID)
    {
        for (int i = 0; i < pickedUpKeys.Count; i++)
        {
            if (pickedUpKeys[i].GetKeyID() == doorID)
            {
                return true;
            }
        }

        return false;
    }

    public List<Key> GetKeysList()
    {
        return pickedUpKeys;
    }
}