示例#1
0
    void Check()
    {
        if (isInChair)
        {
            if (chair.name == "ChairConsumer" && gameObject.name == "Consumer")
            {
                if (Input.ButtonIsDown())
                {
                    Destroy(pizzaCarring);
                    pizzaCarring = null;
                    hasPizza     = false;
                }
            }

            if (chair.name == "ChairProducer" && gameObject.name == "Producer" && pizzaCarring == null)
            {
                if (Input.ButtonIsDown())
                {
                    GameObject pizza = Instantiate(pizzaObj, transform);
                    pizzaCarring = pizza;
                    hasPizza     = true;
                }
            }

            if (chair.name == "Buffer")
            {
                if (Input.ButtonIsDown() && gameObject.name == "Producer" && !chair.GetComponent <Chair>().hasElement&& pizzaCarring != null)
                {
                    pizzaCarring.transform.SetParent(chair.transform);
                    pizzaCarring.transform.position         = chair.transform.position;
                    chair.GetComponent <Chair>().hasElement = true;
                    chair.GetComponent <Chair>().SetElement(pizzaCarring);
                    pizzaCarring = null;
                    hasPizza     = false;
                }
                if (Input.ButtonIsDown() && gameObject.name == "Consumer" && chair.GetComponent <Chair>().hasElement&& pizzaCarring == null)
                {
                    pizzaCarring = chair.GetComponent <Chair>().element;
                    pizzaCarring.transform.SetParent(transform);
                    pizzaCarring.transform.position         = transform.position;
                    chair.GetComponent <Chair>().hasElement = false;
                    hasPizza = true;
                }
            }
        }
    }
示例#2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!isEating)
        {
            Move();
        }
        else if (controller.states[GetNumberOfChair(chair)] == "Hungry")
        {
            TakeForks(chair);
        }

        if (Input.ButtonIsDown() && aButton.activeSelf)
        {
            isEating = true;
            aButton.SetActive(false);
            TakeForks(chair);
        }
    }