Exemple #1
0
    public void UpdateResult()
    {
        Dish result = GetResult();
        Pot  pot    = GameObject.FindObjectOfType <Pot>();

        //pot.Cook(result.cookTime);
        pot.Cook(1f);
        StartCoroutine(CreateDish(result));
    }
Exemple #2
0
    // This method manages what happens when you click on objects. It is called from Update each frame.
    private void UpdateClick()
    {
        RaycastHit hit;
        var        ray = new Ray(cam.transform.position, cam.transform.forward);

        // LEFT CLICK
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit, ClickDistance))
            {
                if (holdObject == null)
                {
                    // If you click on an object ("Item" or "Tool") and you are not currently holding an object, pick it up.
                    if ((hit.transform.gameObject.CompareTag("Item") || hit.transform.gameObject.CompareTag("Tool") ||
                         hit.transform.gameObject.CompareTag("ChoppedFood")) && holdObject == null)
                    {
                        holdObject = hit.transform.gameObject;
                    }

                    if (hit.transform.gameObject.CompareTag("Button"))
                    {
                        //Debug.Log("Clicked BUTTON");
                        pot.Cook();
                    }
                }
                else if (holdObject != null)
                {
                    holdObject = null;
                }
            }
        }

        // RIGHT CLICK
        // If you're holding a TOOL (knife) right click to drop
        if (Input.GetMouseButtonDown(1) && holdObject != null && holdObject.CompareTag("Tool"))
        {
            if (Physics.Raycast(ray, out hit, ClickDistance))
            {
                // If you click an "Item" while holding a "Tool"
                if (hit.transform.gameObject.CompareTag("Item"))
                {
                    // Call the "Item" (the food's) CHOP method
                    hit.transform.gameObject.SendMessageUpwards("Chop");
                    chopSound.Play();
                }
            }
        }
    }