private void CreateStorage(Nutrient.NutrientType type)
    {
        var storage = new NutrientStorage();

        storage.Type = type;
        _storages.Add(storage);
    }
    private void CreateNutrient(Nutrient.NutrientType type)
    {
        var nutrient = new Nutrient(type, _startNutrientsAmount);

        _nutrients.Add(nutrient);
        var counter = Instantiate(_prefab, _counterRoot);

        nutrient.OnNutrientsChanged.AddListener(counter.OnNutrientsChanged);
        counter.OnNutrientsChanged((type, nutrient.GetAmount()));
    }
 public bool Purchase(Nutrient.NutrientType type, int amount)
 {
     foreach (var nutrient in _nutrients)
     {
         if (nutrient.GetNutrientType() == type)
         {
             return(nutrient.PayNutrient(amount));
         }
     }
     return(false);
 }
 public bool AddNutrients(Nutrient.NutrientType type, int amount)
 {
     foreach (var nutrient in _nutrients)
     {
         if (nutrient.GetNutrientType() == type)
         {
             nutrient.AddNutrients(amount);
             return(true);
         }
     }
     return(false);
 }
 public void ClaimStorage(Nutrient.NutrientType type)
 {
     for (var i = 0; i < _storages.Count; ++i)
     {
         if (_storages[i].Type == type)
         {
             if (AddNutrients(type, _storages[i].Amount))
             {
                 _storages[i].Amount = 0;
             }
         }
     }
 }
 public bool AddToStorage(Nutrient.NutrientType type, int amount)
 {
     for (var i = 0; i < _storages.Count; ++i)
     {
         if (_storages[i].Type == type)
         {
             if (_storages[i].Amount >= _storages[i].MaxAmount)
             {
                 return(false);
             }
             _storages[i].Amount = Mathf.Min(_storages[i].Amount + amount, _storages[i].MaxAmount);
             return(true);
         }
     }
     return(false);
 }