示例#1
0
	// 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);
			}
	}
示例#2
0
 public bool AddCustomer(CustomerAI customer)
 {
     if (_customer == null)
     {
         _customer = customer;
         _counterInteraction._customer = customer;
         _coll.enabled = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
    IEnumerator ChooseAggro()
    {
        navAgent.stoppingDistance = attackStoppingDistance;
        while (state != State.dead && state != State.struggling)
        {
            if (target == null || target.state == State.dead || target.state == State.struggling)
            {
                navAgent.enabled = true;
                CustomerAI[] customers = FindObjectsOfType <CustomerAI>();

                if (customers.Length == 1)
                {
                    navAgent.SetDestination(transform.position);
                }
                else
                {
                    CustomerAI closestCustomer = customers[0];
                    float      closestDistance = (closestCustomer.transform.position - transform.position).sqrMagnitude;
                    foreach (CustomerAI customer in customers)
                    {
                        if (customer == this)
                        {
                            continue;
                        }

                        float customerDistance = (customer.transform.position - transform.position).sqrMagnitude;
                        if (customerDistance < closestDistance && customer.state != State.dead)
                        {
                            closestDistance = customerDistance;
                            closestCustomer = customer;
                        }
                    }

                    navAgent.SetDestination(closestCustomer.transform.position);
                    target = closestCustomer;
                }
            }


            yield return(new WaitForSeconds(5));
        }

        navAgent.enabled = false;
    }
示例#4
0
 public void CustomerLeave()
 {
     _customer = null;
     _counterInteraction._customer = null;
     _coll.enabled = false;
 }
示例#5
0
    /*
    ArrayList getEmptyCustomerIndexes()
    {
        ArrayList ec = new ArrayList();
        for (int i=0; i < 5; i++)
        {
            if (!customerList[i])
            {
                ec.Add(i);
            }
        }
        return ec;
    }*/
    public GameObject Spawn(string customerName, CustomerAI cAI)
    {
        //ArrayList emptyCustomers = getEmptyCustomerIndexes();

        //int i = randomCustomerIndexes.Dequeue();

        current_customer = cAI.customer;
        print("FOOD QUEUE:::::" + cAI.customer.foodQueue.Count);
        GameObject tempcustomer = Resources.Load("Customers/Peasants/customer") as GameObject;

        if (current_customer.type == "peasant")
        {
            print("foodqueue: " + current_customer.foodQueue.Count);
            tempcustomer.GetComponent<Customer>().foodQueue = current_customer.foodQueue;
            //tempcustomer.GetComponent<Customer>().current_food = findRecipe(current_customer.foodQueue.Dequeue());
        }

        else if (current_customer.type == "artisan")
        {
            print("foodqueue: " + current_customer.foodQueue.Count);
            tempcustomer.GetComponent<Customer>().foodQueue = current_customer.foodQueue;
            //tempcustomer.GetComponent<Customer>().current_food = findRecipe(current_customer.foodQueue.Dequeue());
        }

        if (CustomerAI.customerSat1 && customerName == "cus_1")// && emptyCustomers.Contains(0))
        {
            tempcustomer.GetComponent<nameAndPosition>().x = 6;
            tempcustomer.GetComponent<nameAndPosition>().y = 2;
            tempcustomer.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1.0f);
            //tempcustomer.transform.position = new Vector3(9, 2, 0);
            customer1 = true;
        }
        else if (CustomerAI.customerSat2 && customerName == "cus_2")// && emptyCustomers.Contains(1))
        {
            tempcustomer.GetComponent<nameAndPosition>().x = 7;
            tempcustomer.GetComponent<nameAndPosition>().y = 2;
            tempcustomer.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1.0f);
            //tempcustomer.transform.position = new Vector3(10.5f, 2, 0);
            customer2 = true;
        }
        else if (CustomerAI.customerSat3 && customerName == "cus_3")// && emptyCustomers.Contains(2))
        {
            tempcustomer.GetComponent<nameAndPosition>().x = 8;
            tempcustomer.GetComponent<nameAndPosition>().y = 2;
            tempcustomer.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1.0f);
            //tempcustomer.transform.position = new Vector3(12, 2, 0);
            customer3 = true;
        }
        else if (CustomerAI.customerSat4 && customerName == "cus_4")// && emptyCustomers.Contains(3))
        {
            tempcustomer.GetComponent<nameAndPosition>().x = 9;
            tempcustomer.GetComponent<nameAndPosition>().y = 2;
            tempcustomer.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1.0f);
            //tempcustomer.transform.position = new Vector3(13.5f, 2, 0);
            customer4 = true;
        }
        else if (CustomerAI.customerSat5 && customerName == "cus_5")// && emptyCustomers.Contains(4))
        {
            tempcustomer.GetComponent<nameAndPosition>().x = 10;
            tempcustomer.GetComponent<nameAndPosition>().y = 2;
            tempcustomer.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1.0f);
            //tempcustomer.transform.position = new Vector3(15, 2, 0);
            customer5 = true;
        }

        return Instantiate(tempcustomer);

        /*
        for (int i = 0; i < 5; i++)
        {
            if (!customerList[i] && peasantFoodQueue.Count > 0)
            {
                //spawn
                GameObject tempcustomer = Resources.Load("Customers/Peasants/customer") as GameObject;

                tempcustomer.GetComponent<Customer>().current_food = findRecipe(peasantFoodQueue.Dequeue());
                if (i == 0)
                {
                    tempcustomer.GetComponent<nameAndPosition>().x = 6;
                    tempcustomer.GetComponent<nameAndPosition>().y = 2;
                    tempcustomer.transform.position = new Vector3(9, 2, 0);
                    customer1 = true;
                }
                else if (i == 1)
                {
                    tempcustomer.GetComponent<nameAndPosition>().x = 7;
                    tempcustomer.GetComponent<nameAndPosition>().y = 2;
                    tempcustomer.transform.position = new Vector3(10.5f, 2, 0);
                    customer2 = true;
                }
                else if (i == 2)
                {
                    tempcustomer.GetComponent<nameAndPosition>().x = 8;
                    tempcustomer.GetComponent<nameAndPosition>().y = 2;
                    tempcustomer.transform.position = new Vector3(12, 2, 0);
                    customer3 = true;
                }
                else if (i == 3)
                {
                    tempcustomer.GetComponent<nameAndPosition>().x = 9;
                    tempcustomer.GetComponent<nameAndPosition>().y = 2;
                    tempcustomer.transform.position = new Vector3(13.5f, 2, 0);
                    customer4 = true;
                }
                else if (i == 4)
                {
                    tempcustomer.GetComponent<nameAndPosition>().x = 10;
                    tempcustomer.GetComponent<nameAndPosition>().y = 2;
                    tempcustomer.transform.position = new Vector3(15, 2, 0);
                    customer5 = true;
                }
                customerList[i] = Instantiate(tempcustomer);
            }

        }
        */

        //OLD SPAWN
        /*
        if (!waitingForC1 && peasantFoodQueue.Count > 0)
        {
            _c1 = Instantiate(c1);
            _c1.GetComponent<Customer>().current_food = findRecipe(peasantFoodQueue.Dequeue());
            waitingForC1 = true;
        }
        if (!waitingForC2 && peasantFoodQueue.Count > 0)
        {
            _c2 = Instantiate(c2);
            _c2.GetComponent<Customer>().current_food = findRecipe(peasantFoodQueue.Dequeue());
            waitingForC2 = true;
        }*/
    }
示例#6
0
	private void takeCustomerOrder(GameObject customer) {
		currentCustomer = customer.GetComponent<CustomerAI>();
		agent.SetDestination (customer.gameObject.transform.position);
		anim.SetInteger("Transition", 1);
		//findStove();
	}
示例#7
0
	public void reset()
	{
		state = waiterStates.NOTHING;
		currentCustomer = null;
		currentFood = null;
		currentStove = null;
	}
示例#8
0
 private void Start()
 {
     customer_ai = customer_rb.GetComponent <CustomerAI>();
 }
示例#9
0
 public void LeaveLine(CustomerAI customer)
 {
     _customerQueue.Remove(customer);
 }
示例#10
0
 public void GetInLine(CustomerAI customer)
 {
     _customerQueue.Add(customer);
 }