Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using Object = UnityEngine.Object;
- public class InventoryManager : MonoBehaviour
- {
- private Dictionary<Type, List<Ingredient>> items = new Dictionary<Type, List<Ingredient>>();
- [SerializeField] private List<Ingredient> _ingredient = new List<Ingredient>();
- private WobblingConnector _wobblingConnector;
- private void Start()
- {
- _wobblingConnector = FindObjectOfType<WobblingConnector>(); //Better rework this, because it's not so good.
- SearchAllAndAddToDictionary();
- }
- private void SearchAllAndAddToDictionary()
- {
- foreach (Ingredient item in _wobblingConnector._itemsInBackpack)
- {
- AddToDictionary(item);
- }
- }
- public void AddToDictionary(Ingredient item)
- {
- _ingredient.Add(item);
- var type = item.GetType();
- if(!items.ContainsKey(type))
- {
- items.Add(type , new List<Ingredient>(){item});
- }
- else
- {
- items[type].Add(item);
- }
- Debug.Log(ingredient);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement