private IEnumerator CookAnimate(ICookable cookable) { float time = cookable.GetTotalDuration(); float elapsed = cookable.GetReadiness(); _cookable = cookable.GetTransform(); _cookable.SetParent(_cookingObjectParent); _cookable.localPosition = Vector3.zero; _cookable.localRotation = Quaternion.identity; _steam.Play(); while (elapsed < time && _cookable != null) { cookable.Cook(elapsed); _ui.SetCookingState(cookable.GetTotalDuration(), cookable.GetReadiness()); elapsed += Time.deltaTime; yield return(null); } }
/// <summary> /// New common functionality for ICookable /// </summary> /// <param name="food"></param> public void Eat(ICookable food) { food.Cook(); Console.WriteLine("Wait 5 minutes and eat"); }