private void Update() { if (!paused) { if (status == (int)Status.OCCUPIED) { timer += Time.deltaTime * 1000; if (timer > orderTime) { if (tutorial && !takeOrdersTutorialDisplayed) { takeOrdersTutorialDisplayed = true; tutorialController.Display("takeOrders", 1000); } status = (int)Status.ORDERING; timer = 0.0f; itemOrdered = mitemsScriptRef.menu[Random.Range(0, mitemsScriptRef.menu.Length)]; messageScript.AddImage(itemOrdered.foodImage); tag = "ordering_table"; } } if (status == (int)Status.EATING) { timer += Time.deltaTime * 1000; if (timer > eatingTime) { if (tutorial && !tipsTutorialDisplayed) { tipsTutorialDisplayed = true; tutorialController.Display("tip", 200); } status = (int)Status.PAYING; timer = 0.0f; Destroy(foodReference); tip = occupingCustomer.GetComponent <customerManager>().tip; tipReference = Instantiate(tipPrefab); tipReference.transform.localPosition = trayPosition.position; occupingCustomer.GetComponent <customerManager>().LeaveTable(); tag = "collect_tip"; status = (int)Status.COLLECT_BILL; } } } }
private void Update() { if (!paused) { timer += (Time.deltaTime * 1000); if (nextSpawn <= timer) { if (tutorial && !customerArrivalTutorialDisplayed) { customerArrivalTutorialDisplayed = true; tutorialController.Display("customerArrival", 2000); } nextSpawn = timer + Random.Range(minCustArrival, maxCustArrival); if (tutorial) { nextSpawn = 500000; } int luckyCustomer = Random.Range(0, prefab.Length); if (noOfWaitingCustomers != waitingQueue.Length) { GameObject tempCustomer = Instantiate(prefab[luckyCustomer], waitingQueue[0].transform.position, waitingQueue[0].transform.rotation); tempCustomer.GetComponent <customerManager>().exit = exit; for (int i = waitingQueue.Length - 1; i >= 0; i--) { if (!customerWaitingAtPosition[i]) { if (i == waitingQueue.Length - 1) { tempCustomer.tag = "WaitingCustomer"; } NavMeshAgent nav = tempCustomer.GetComponent <NavMeshAgent>(); nav.enabled = true; tempCustomer.GetComponent <customerManager>().customerAnimator.SetBool("walking", true); nav.speed = customerSpeed; nav.SetDestination(waitingQueue[i].transform.position); customerWaitingAtPosition[i] = true; waitingCustomers[i] = tempCustomer; break; } } noOfWaitingCustomers++; } } } }
private void Update() { if (!paused) { if (currentStatus == status.FREE && cookingQueue.Count != 0) { currentlyCooking = cookingQueue.Dequeue(); currentStatus = status.COOKING; } if (currentStatus == status.COOKING) { currentTimer += Time.deltaTime * 1000; if (currentTimer > cookingTime) { currentTimer = 0; if (!foodInCounter) { if (tutorial && !foodReadyTutorialDisplayed) { foodReadyTutorialDisplayed = true; tutorialController.Display("foodReady", 1000); } spawnedFood = Instantiate(currentlyCooking.obj); spawnedFood.tag = "food_in_kitchen"; menuItemInCounter = currentlyCooking; spawnedFood.transform.parent = orderReleasePosition; spawnedFood.transform.localPosition = Vector3.zero; spawnedFood.transform.localScale = Vector3.one; currentStatus = status.FREE; currentlyCooking = null; foodInCounter = true; } else { currentStatus = status.WAITING_FOR_COUNTER; } } } } }
private void Update() { if (currentStatus == (int)status.MOVING_TO_TABLE && nav.remainingDistance < 8) { playerAnimator.SetBool("walking", false); tableScript tsRef = currentApproachingTable.GetComponent <tableScript>(); if (!currentApproachingTable.GetComponent <tableScript>().isFree()) { if (tutorial && !placeOrderTutorialDisplayed) { placeOrderTutorialDisplayed = true; tutorialController.Display("placeOrder", 500); } transform.position = tsRef.waitingPosition.position; transform.rotation = tsRef.waitingPosition.rotation; tsRef.arrow.enabled = false; tsRef.orderTaken(this); calculateArrows(); } nav.enabled = false; currentStatus = (int)status.FREE; } else if (currentStatus == (int)status.MOVING_TO_KITCHEN && nav.remainingDistance < 5) { playerAnimator.SetBool("walking", false); currentStatus = (int)status.FREE; nav.enabled = false; kitchenScript ksRef = kitchenCounter.GetComponent <kitchenScript>(); transform.position = ksRef.orderingPosition.position; transform.rotation = ksRef.orderingPosition.rotation; while (orders.Count != 0) { ksRef.addToCooking(orders.Dequeue()); } if (ksRef.foodReady() && !handFull) { if (tutorial && !servingCustomerTutorialDisplayed) { servingCustomerTutorialDisplayed = true; tutorialController.Display("servingCustomer", 100); } foodInHand = ksRef.ReleaseFood(); handFull = true; tableScript tsRef = currentApproachingTable.GetComponent <tableScript>(); foodInHandReference = Instantiate(foodInHand.obj, handPosition); foodInHandReference.transform.localPosition = new Vector3(0, 0, 0); foodInHandReference.transform.localScale = Vector3.one; gameController.GetComponent <arrowManager>().ReCalculateArrows(foodInHand.name); } } else if (currentStatus == (int)status.MOVING_TO_SERVE && nav.remainingDistance < 8) { playerAnimator.SetBool("walking", false); nav.enabled = false; currentStatus = (int)status.FREE; if (!currentApproachingTable.GetComponent <tableScript>().isFree()) { if (tutorial && !trashTutorialDisplayed) { trashTutorialDisplayed = true; tutorialController.Display("trash", 100); } handFull = false; tableScript tsRef = currentApproachingTable.GetComponent <tableScript>(); Destroy(foodInHandReference); tsRef.serveFood(); transform.position = tsRef.waitingPosition.position; transform.rotation = tsRef.waitingPosition.rotation; calculateArrows(); } } else if (currentStatus == (int)status.COLLECTING_TIP && nav.remainingDistance < 8) { playerAnimator.SetBool("walking", false); tableScript tsRef = currentApproachingTable.GetComponent <tableScript>(); currentStatus = (int)status.FREE; nav.enabled = false; transform.position = tsRef.waitingPosition.position; transform.rotation = tsRef.waitingPosition.rotation; int cashInHand = tsRef.CollectTip(); gameController.GetComponent <MoneyManager>().AddScore(cashInHand); if (tutorial) { tutorialController.Display("end", 100); } } else if (currentStatus == (int)status.MOVING_TO_TRASH && nav.remainingDistance < 5) { playerAnimator.SetBool("walking", false); nav.enabled = false; currentStatus = (int)status.FREE; Destroy(foodInHandReference); handFull = false; transform.position = trashPosition.position; transform.rotation = trashPosition.rotation; calculateArrows(); } else if (currentStatus == (int)status.MOVING_TO_QUEUE && nav.remainingDistance < 5) { if (tutorial && !seating2CustomerTutorialDisplayed) { seating2CustomerTutorialDisplayed = true; tutorialController.Display("seating2", 100); } playerAnimator.SetBool("walking", false); nav.enabled = false; currentStatus = (int)status.FREE; transform.position = waitingQueuePosition.position; transform.rotation = trashPosition.rotation; gameController.GetComponent <CustomerSelector>().selectCustomer(); } }