Example #1
0
 // Loads and runs the dialogue tree provided
 // Takes in a Customer that will be leaving after the dialogue is done
 public void LoadAndRun(Dialogue dialogue, Restaurant_CustomerController customerToLeave)
 {
     currentCustomer = customerToLeave;
     LoadDialogue(dialogue);
     RunCurrentDialogue();
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (!holdingItem && Keybinds.WasTriggered(Keybind.Interact))
        {
            GameObject closestFoodItem = FindClosestWithTag("FoodToServe");
            if (closestFoodItem)
            {
                // Pick up food from counter
                string selectedDish = closestFoodItem.name;
                selectedDish = selectedDish.Remove(selectedDish.Length - 7); // Remove the "(Clone)"


                int foodId = -2;

                /*
                 * if (selectedDish == ("plateDinner(Clone)") )
                 *  foodId = 0;
                 * else if (selectedDish == ("bowlBroth(Clone)") )
                 *  foodId = 1;
                 * else if (selectedDish == ("pizza(Clone)") )
                 *  foodId = 2;
                 * else if (selectedDish == ("burrito(Clone)") )
                 *  foodId = 3;
                 */
                for (int i = 0; i < foodPrefabs.Length; i++)
                {
                    if (foodPrefabs[i].name == selectedDish)
                    {
                        foodId = i;
                        break;
                    }
                }
                CollectFood(foodId, foodLocation.position);
                Destroy(closestFoodItem); // comment this out if want unlimited servings of the dish after cooking
            }
            else
            {
                // Try interacting with closest Customer
                GameObject closestCustomer = FindClosestWithTag("Customer");
                // Serve the customer if carrying food
                if (closestCustomer)
                {
                    Restaurant_CustomerController customerController =
                        closestCustomer.GetComponent <Restaurant_CustomerController>();
                    // Only serve food to Customers not already eating
                    if (customerController.HasReceivedFood() && customerController.HasDialogue())
                    {
                        movementController.DisableMovementOfPlayer();
                        dialogueLoader.LoadAndRun(DialogueDatabase.GetRandomDialogue(), customerController);
                        customerController.SetToNoDialogue();
                    }
                }
            }
        }
        else if (holdingItem && Keybinds.WasTriggered(Keybind.Trash))
        {
            DestroyHeldFood();
        }
        else if (holdingItem && Keybinds.WasTriggered(Keybind.Interact))
        {
            GameObject closestCustomer = FindClosestWithTag("Customer");
            // Serve the customer if carrying food
            if (closestCustomer)
            {
                Restaurant_CustomerController customerController =
                    closestCustomer.GetComponent <Restaurant_CustomerController>();
                // Only serve food to Customers not already eating
                if (!customerController.HasReceivedFood())
                {
                    ServeFood(closestCustomer, currentHeldFood);
                }
            }
        }
    }