|
|
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- [CreateAssetMenu(menuName = "Major Project/Inventory", order = 150)]
- public class Inventory : ScriptableObject
- {
- [SerializeField]
- protected List<InventoryData> AllElements = new List<InventoryData>();
-
- public void Add(LogicBlock element)
- {
-
- InventoryData data;
-
- try
- {
- data = AllElements.First(p => p.element == element);
- }
- catch
- {
- data = new InventoryData() { element = element };
- AllElements.Add(data);
- }
-
- data.Count++;
- }
-
- public void Remove(LogicBlock element) {
-
- if (!AllElements.Exists(p => p.element == element))
- return;
-
- InventoryData data = AllElements.First(p => p.element == element);
-
- if (!data.infinit)
- data.Count--;
- }
-
-
-
- [System.Serializable]
- public class InventoryData
- {
- public LogicBlock element;
- public int Count;
- public bool infinit = false;
- }
- }
|