示例#1
0
    //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);
    }
示例#2
0
    public void SetPreparingFood(PreparingFood food)
    {
        this.food = food;
        gameObject.SetActive(food != null);

        if (food == null)
        {
            return;
        }
        image.sprite = food.recipe.food.sprite;
    }
示例#3
0
 //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;
         }
     }
 }
示例#4
0
    //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);
    }
示例#5
0
    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);
    }