private void Eat(GameObject food) { IFood foodItem = food.GetComponent <IFood>(); if (foodItem != null) { float calories = foodItem.GetEaten(); RestoreEnergy(calories); } }