IEnumerator EatCheck()
    {
        for (; ;)
        {
            yield return(null);

            Transform edibleTransform = _eatArea.GetClosestEdible();

            if (edibleTransform == null)
            {
                continue;
            }

            IEdible edible = edibleTransform.GetComponent <IEdible>();

            if (edible == null)
            {
                continue;
            }

            _objectiveManager.OnAteEdible(_player);
            edible.OnEat();

            yield return(new WaitForSeconds(_eatCooldown));
        }
    }
Exemple #2
0
 private void Update()
 {
     for (int i = _currentEdibles.Count - 1; i >= 0; i--)
     {
         GameObject edibleObject = _currentEdibles[i];
         if (edibleObject.layer != GrabObject.GRABBEDLAYER)
         {
             IEdible edible = edibleObject.GetComponent <IEdible>();
             edible.OnEat();
             _currentEdibles.RemoveAt(i);
         }
     }
 }