//Find and remove the food we wish to stop preparing //Invoke OnFoodCanceledPreparing if we do public bool StopPreparingFood(PreparingFood food) { if (foodsBeingPrepared.Remove(food)) { OnFoodCanceledPreparing?.Invoke(food); return(true); } return(false); }
public void SetPreparingFood(PreparingFood food) { this.food = food; gameObject.SetActive(food != null); if (food == null) { return; } image.sprite = food.recipe.food.sprite; }
//Finds a preparingFoodUI that's empty and sets it to the given value private void FoodPreparing(PreparingFood food) { foreach (PreparingFoodUI foodUI in preparingFoodUIs) { if (foodUI.GetPreparingFood() == null) { foodUI.SetPreparingFood(food); break; } } }
//Finds a customer to serve the item to public bool ServeFood(PreparingFood food) { //Find all customers with our given item List <Customer> waitingCustomers = customers.FindAll((Customer customer) => customer.order == food.recipe.food); if (waitingCustomers.Count >= 1) { return(ServeFood(food, GetLongestWaitingCustomer(waitingCustomers))); } return(false); }
public bool ServeFood(PreparingFood food, Customer customer) { if (customer.order != food.recipe.food) { return(false); } //Remove the customer from our list, and fire the event customers.Remove(customer); OnCustomerServed?.Invoke(customer); //Remove the item for our list and fire the event foodsBeingPrepared.Remove(food); OnFoodFinishedPreparing?.Invoke(food); return(true); }