// Update is called once per frame void Update () { if(state == waiterStates.NOTHING) { checkForCustomer(); if(state == waiterStates.NOTHING) checkForFoodWaiting(); } if (state == waiterStates.TAKING_ORDER && currentCustomer != null) if(Vector3.Distance (currentCustomer.transform.position, agent.nextPosition) <= 1f) { currentStove = findFreeStove(); //Debug.Log("Inside here"); if(currentStove == null) { Debug.Log("CURRENT STOVE IS NULL"); state = waiterStates.NOTHING; currentCustomer.hasWaiter = false; currentCustomer = null; } else { //Debug.Log("Found a stove. Moving there now"); currentFood = currentCustomer.giveOrder(); anim.SetInteger("Transition", 1); //Debug.Log("Got the order"); agent.SetDestination(currentStove.gameObject.transform.position); //currentCustomer = null; state = waiterStates.ORDER_TO_STOVE; } } if(state == waiterStates.ORDER_TO_STOVE && currentStove != null) if(Vector3.Distance(currentStove.transform.position, agent.nextPosition) <= 1.2f) { //Debug.Log("Got to stove"); agent.ResetPath(); currentStove.GetComponent<StoveScript>().acceptFood(currentFood); currentStove = null; currentFood = null; currentCustomer = null; state = waiterStates.NOTHING; anim.SetInteger("Transition", 0); } if (state == waiterStates.PICKING_UP_ORDER && currentStove != null) if(Vector3.Distance (currentStove.transform.position, agent.nextPosition) <= 1.2f) { //Debug.Log("AT THE F*****G STOVE"); currentFood = currentStove.GetComponent<StoveScript>().giveFood(); currentCustomer = currentFood.customer.gameObject.GetComponent<CustomerAI>(); agent.SetDestination(currentCustomer.transform.position); state = waiterStates.DELIVERING_ORDER; anim.SetInteger("Transition", 1); } if(state == waiterStates.DELIVERING_ORDER && currentCustomer != null) if(Vector3.Distance(currentCustomer.transform.position, agent.nextPosition) <= 1.5f) { agent.ResetPath(); currentCustomer.acceptFood(); state = waiterStates.NOTHING; currentCustomer = null; anim.SetInteger("Transition", 0); } }
public void reset() { state = waiterStates.NOTHING; currentCustomer = null; currentFood = null; currentStove = null; }
private void checkForFoodWaiting() { GameObject[] stovesTag = GameObject.FindGameObjectsWithTag("Stove"); List<GameObject> stoves = new List<GameObject>(); for(int j = 0; j < stovesTag.Length; j++) { if(stovesTag[j].gameObject.GetComponent<PlaceableObject>().isPreview == false && stovesTag[j].gameObject.GetComponent<StoveScript>() != null) { if(stovesTag[j].gameObject.GetComponent<StoveScript>().state == StoveScript.stoveStates.FOOD_READY && stovesTag[j].gameObject.GetComponent<StoveScript>().hasWaiter == false) { //Debug.Log("FOUND READY FOOD"); stoves.Add(stovesTag[j]); stoves[0].gameObject.GetComponent<StoveScript>().hasWaiter = true; state = waiterStates.PICKING_UP_ORDER; currentStove = stoves[0]; agent.SetDestination (stoves[0].gameObject.transform.position); anim.SetInteger("Transition", 1); return; //pickUpFood(stoves[0]); } } } }
private void pickUpFood(GameObject stove) { Debug.Log ("PICKING UP FOOD"); state = waiterStates.PICKING_UP_ORDER; currentStove = stove; agent.SetDestination (stove.gameObject.transform.position); anim.SetInteger("Transition", 1); }
private void checkForCustomer() { customers = GameObject.FindGameObjectsWithTag("Customer"); if (customers != null) { for (int i = 0; i < customers.Length; i++) { //Debug.Log (customers.Length); CustomerAI cust = customers [i].gameObject.GetComponent<CustomerAI> (); if (cust != null) { if(cust.state == CustomerAI.customerStates.WAITING && cust.hasWaiter == false) { //Debug.Log("Found customer waiting"); state = waiterStates.TAKING_ORDER; cust.hasWaiter = true; takeCustomerOrder (customers [i]); break; } } } } }