void Start() { //gamepause = true; gamepause = false; button = GameObject.Find("NextRecipeButton").GetComponent <Button>(); theCustomer = GameObject.Find("Customer").GetComponent <CustomerScript>(); }
void SpawnCustomer() { //instantiate customer and obtain a reference of there customerscript inLine.Add(Instantiate(customers[0], spawnPoint, Quaternion.identity, gameObject.transform)); GameObject newCustomer = GameObject.Find("Customer(Clone)"); CustomerScript customerScript = newCustomer.GetComponent <CustomerScript>(); //change the name of the customer customerScript.AssignCustomerName(); }
// Start is called before the first frame update private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } }
public void DeleteCustomers(CustomerScript script) { customerScripts.Remove(script); if (activeCustomers.Count != 0) { activeCustomers[0].SetActive(false); idleCustomers.Add(activeCustomers[0]); activeCustomers.RemoveAt(0); } }
public void MoveLineUp() { for (int i = 0; i <= inLine.Count - 1; i++) { //Debug.Log("MoveLineUp iteration = " + i); if (Vector3.Distance(inLine[i].transform.position, queuePositions[i]) > Mathf.Epsilon) { CustomerScript customerScript = inLine[i].GetComponent <CustomerScript>(); customerScript.customerMove(queuePositions[i]); } } }
void Start() { customerScript = FindObjectOfType <CustomerScript>(); if (inventoryCanvas.isActiveAndEnabled) { inventoryCanvas.gameObject.SetActive(false); } if (dialoguePanel.activeInHierarchy) { dialoguePanel.gameObject.SetActive(false); } openInventory = true; BackOfHouseButton.gameObject.SetActive(true); }
//function that tests the customer order vs what the player has. If it's wrong, //the customwer will get mad, otherwise the salad is taken out of the queue and //the player gets 200 points void CheckCustomerOrder(SaladScriptObj playerSalad, CustomerScript customer) { SaladScriptObj custOrder = customer.order; if (playerSalad == custOrder) { TakeItemFromQueue(); playerInfo.score += 200; customer.OrderDelivered(this); } else { customer.CustomerGetsAngry(); } }
private bool CompareOrders() { _customer = GameObject.FindGameObjectWithTag("Customer").GetComponent <CustomerScript>(); List <GameObject> playerList = Player.SelectedItems; List <GameObject> customerList = _customer.WantedItems; if (playerList.Count != customerList.Count) //if the amount of items is different, the order is wrong { return(false); } /*foreach( GameObject item in playerList) * { * if (customerList.Contains(item) && item != null) * { * customerList.Remove(item); * playerList.Remove(item); * } * }*/ for (int i = 0; i < playerList.Count; i++) { GameObject currentObject; if (playerList[i] != null) { currentObject = playerList[i]; } else { Debug.Log("Item in list is null"); currentObject = this.gameObject; } if (customerList.Contains(currentObject)) { customerList.Remove(currentObject); playerList.RemoveAt(i); } } if (playerList.Count == 0 && customerList.Count == 0) { return(true); } return(false); }
// Update is called once per frame void FixedUpdate() { if (ScoreScript.gameOver) { return; } this._time += Time.deltaTime; if (this._time >= this._maxtime) { CustomerScript customer = this.customer.GetComponent <CustomerScript>(); if (!customer.isMoving()) { customer.spawn(this.getRandomSpawn(), otherWall.transform.position); this.setTimer(Random.Range(5, 10)); } } }
public void GiveCustomerDrinks(CustomerScript customer) { for (int i = 0; i < customer.drinksWanted.Count; i++) { for (int j = 0; j < inventory.playerDrinks.Count; j++) { Debug.Log("looking for " + customer.drinksWanted[i] + " in customer slot number " + i + " in player slot number " + j); //to avoid a nullreferenceexeption, if the drinks index is null, skip it to the next iteration of the loop if (inventory.playerDrinks[j] == null) { continue; } if (customer.drinksWanted[i] == inventory.playerDrinks[j].drinks_SOs) { //Debug.Log("the player has it in slot " + j); //update inventory and the customers requested items customer.drinksWanted[i] = null; inventory.playerDrinks[j] = null; inventory.NewAssignToDisplay(j); inventory.itemInInventory = inventory.CountItemsInIneventory(); //as well as reset the quality linked to that drink inventory.drinkQuality[j] = 0; //check if the customer still needs drinks customer.drinksNeeded = customer.checkNumberOfDrinksNeeded(); customer.isWaitng = customer.checkIfCustomerIsDone(customer.drinksNeeded); //if done - get them away if (customer.isWaitng == false) { customer.customerLeave(); } break; } } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { if (objectCastingOn.tag == "DrinkStorage") { itemCollection.AddItemToInventory(); } if (objectCastingOn.tag == "Customer") { CustomerScript customerScript = objectCastingOn.GetComponent <CustomerScript>(); giveToCustomer.GiveCustomerDrinks(customerScript); } } //creates a ray and draws it in the scene view //RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up, interactionLength, mask); //Debug.DrawRay(transform.position, transform.up * interactionLength, Color.green); //check if collider hits the DrinkStorage tag //if(hit.collider != null) //{ // //Debug.Log("hitting" + hit.collider.gameObject.name); // if(hit.collider.tag == "DrinkStorage") // { // //reference the itemcollection script on contact // ItemCollection collection = hit.collider.GetComponent<ItemCollection>(); // //hit space to query if drink can be picked up // if (Input.GetKeyDown(KeyCode.Space)) // { // //check if there is room in inventory // if(inventory.itemInInventory < inventory.inventoryCapacity) // { // Debug.Log("there is space in inventory, now collecting..."); // //set the drink in the first null found on the list // int x = inventory.playerDrinks.IndexOf(null); // inventory.playerDrinks[x] = collection.drink; // //set the quality at the same list index; // inventory.drinkQuality[x] = collection.drink.quality; // inventory.NewAssignToDisplay(x); // inventory.itemInInventory = CountItemsInIneventory(); // inventory.ListInventoryItems(); // } // else // { // Debug.Log("no space in inventory!"); // } // } // } // if(hit.collider.tag == "Customer") // { // if(Input.GetKeyDown (KeyCode.Space)) // { // //get a reference to the customer script // CustomerScript customerScript = hit.collider.gameObject.GetComponent<CustomerScript>(); // for (int i = 0; i < customerScript.drinksWanted.Count; i++) // { // for (int j = 0; j < inventory.playerDrinks.Count; j++) // { // //Debug.Log("looking for " + customerScript.drinksWanted[i] + " in customer slot number " + i + " in player slot number " + j); // //to avoid a nullreferenceexeption, if the drinks index is null, skip it to the next iteration of the loop // if(inventory.playerDrinks[j] == null) // { // continue; // } // if (customerScript.drinksWanted[i] == inventory.playerDrinks[j].drinks_SOs) // { // //Debug.Log("the player has it in slot " + j); // //update inventory and the customers requested items // customerScript.drinksWanted[i] = null; // inventory.playerDrinks[j] = null; // inventory.NewAssignToDisplay(j); // inventory.itemInInventory = CountItemsInIneventory(); // //as well as reset the quality linked to that drink // inventory.drinkQuality[j] = 0; // //check if the customer still needs drinks // customerScript.drinksNeeded = customerScript.checkNumberOfDrinksNeeded(); // customerScript.isWaitng = customerScript.checkIfCustomerIsDone(customerScript.drinksNeeded); // //if done - get them away // if(customerScript.isWaitng == false) // { // customerScript.customerLeave(); // } // break; // } // } // } // } // } //} }