IEnumerator MoveWaiter(Transform areaPos, Move_S plate, GameObject waiter) { yield return(agent.SetDestination(areaPos.position + Vector3.forward)); //moving waiter to table while (agent.remainingDistance > agent.stoppingDistance) //making sure its close enough { yield return(null); } yield return(StartCoroutine(RotateAnObject(agent.transform.right, shoulder, shoulder, -60, .2f))); plate.CheckForFood(); plate.DisablePhysics(plateSlot); plate.GetMarker().SetOccupation(false);//getting access to objects physics yield return(StartCoroutine(Move(plate.transform, .3f))); yield return(agent.SetDestination(end.position)); yield return(new WaitForSeconds(1)); StartCoroutine(DoorMovement(Vector3.up, -120, 1)); while (agent.remainingDistance > .1f) { yield return(null); } Destroy(waiter); }
bool CheckForChildren(Food_O bottom) //checking if the food has children and configuring accordingly { Food_O[] food = bottom.GetComponentsInChildren <Food_O>(); Move_S m = bottom.GetComponentInParent <Move_S>(); //if the foo is stacked, bottom is the food at the bottom of the stack if (bottom.GetFreshness()) //untouched food { if (manager != null) //cheap way to configure, checking scene basically { if (manager.GetItemPrice(bottom.GetName())) //if can afford { bottom.SetFreshness(false); } else { return(false); } } } i.OnPickUp(bottom.transform); if (m != null) //checking if on board/ plate / tray { for (int i = 0; i < food.Length; i++) { food[i].SetOnSurface(false); m.ListOfFood().Remove(food[i]); //removing the food from the script list } if (firstOnStack != null || stack == 1) //if theres a stack or singular food { m.MarkerList().Add(bottom.GetMarker()); //readding the marker to the board/plate/tray for future bottom.SetMarker(null); } if (m.startedWithFood) //checking if the surface needs replenishing { if (m.ListOfFood().Count == 0) { StartCoroutine(m.RestockFood(m.foodType, .2f)); } } } for (int i = 0; i < food.Length; i++) //for all food, be it one or more { food[i].stack = i + 1; //changing the food variables food[i].ChangeDrag(3); if (CheckObjectCount.objects.Contains(food[i].gameObject)) { CheckObjectCount.objects.Remove(food[i].gameObject); } if (food[i] != bottom) { food[i].DisablePhysics(food[i - 1].transform); } food[i].inStack = false; } return(true); }
void OnDrop(RaycastHit hit) { SetPhysics(null); GameObject obj = GetHolding().GetObject(); newColider = false; if (obj.GetComponent <Move_S>() != null) //board/plate/tray dropped { if (obj.CompareTag("Plate")) //checking if its a plate { if (Physics.Raycast(guide.position, -Vector3.up, out hit, 5f)) { float dist = Vector3.Distance(guide.position, hit.point); StartCoroutine(BreakStuff(dist, obj)); } } Move_S m = GetHolding().GetObject().GetComponent <Move_S>(); if (m.ListOfFood().Count > 0) //checking if theres food on the object { foreach (Food_O f in m.ListOfFood()) //resetting varibales for each food object { f.GetComponent <IPhysics>().GetMarker().SetOccupation(false); f.SetOnSurface(false); f.ChangeDrag(3); f.firstOnStack = null; f.SetMarker(null); StartCoroutine(CheckObjectCount.CheckPrefabCount(f.gameObject)); GameManager.dropCount++; } m.ListOfFood().Clear(); } m.MarkerList().Clear(); m.AddMarkerChildren(); } else if (obj.GetComponent <Food_O>() != null) //if food dropped { Food_O food = obj.GetComponent <Food_O>(); StartCoroutine(CheckObjectCount.CheckPrefabCount(food.gameObject)); if (food.foodStack.Count > 0) { foreach (Food_O f in food.foodStack) //resetting varibales { f.firstOnStack = null; StartCoroutine(CheckObjectCount.CheckPrefabCount(f.gameObject)); GameManager.dropCount++; f.GetMarker().SetOccupation(false); f.SetMarker(null); } food.foodStack.Clear(); } } SetInteract(null); }
void DisallowInteraction(Move_S plate) //not allowing the player to touch the plate/food once its been sent { plate.SetInteract(false); Food_O[] foodOnPlate = plate.GetComponentsInChildren <Food_O>(); if (foodOnPlate != null) { foreach (Food_O f in foodOnPlate) { f.SetInterct(false); } } }
void SendMeal() { Move_S plateS = i.GetHolding().GetObject().GetComponent <Move_S>(); if (gameManager != null) { gameManager.SendMeal(plateS.ListOfFood(), ticket, plateS); } else { practise.SendMeal(plateS.ListOfFood(), ticket, plateS); } }
public IEnumerator RestockShelf(GameObject type, float time) { if (plate != null) { for (int i = 0; i < plateMarkers.Count; i++) { GameObject p = Instantiate(plate, plateMarkers[i].transform.position, Quaternion.identity); Move_S surface = p.GetComponentInChildren <Move_S>(); surface.SetMarker(plateMarkers[i]); plateMarkers[i].SetOccupation(true); plates.Add(surface); p.transform.SetParent(transform); yield return(new WaitForSeconds(time)); } } }
public void SendMeal(List <Food_O> food, MealTicket ticket, Move_S plate) { MealAssessment assessment = new MealAssessment(food, ticket, menu, mealsThrough); ticket.pauseTimer = true; assessment.AssessMeal(); double moneyBack = assessment.Money(); StartCoroutine(UpdateMoney(moneyBack, moneyBack / 10d)); daysEarnings += moneyBack; int mealIndex = mealTickets.IndexOf(ticket); mealTickets.Remove(mealTickets[mealIndex]); mealsThrough++; StartCoroutine(ShowResults(assessment)); StartCoroutine(waiter.GetWaiter(sendAreas[ticket.GetScreen().screenNo - 1].transform, plate)); mealAssesments.Add(assessment.AssessmentText()); }
void PutFoodOnFood(GameObject obj) //when food is in hand and want to place on other food. { Food_O[] food = obj.GetComponentsInChildren <Food_O>(); Food_O last = food[food.Length - 1]; //getting the last in the stack, may only be the one if (last.stack + stack <= 7 && !inStack) //may change stack limit { PlaceMarker m = i.GetMarker(gameObject); if (m != null) { for (int i = 0; i < food.Length; i++) { food[i].ChangeDrag(food[i].defaultDrag); //restting the drag and stack varibales if (food[i] != obj.GetComponent <Food_O>()) { food[i].stack = food[i - 1].stack + 1; } else { food[i].stack = stack + 1; } } if (GetParents() != null) { Food_O bottom = GetParents()[GetParents().Length - 1];//getting item at the bottom of the stack foreach (Food_O f in food) { bottom.foodStack.Add(f); //reordering the stack f.firstOnStack = bottom; } } Move_S move = m.GetComponentInParent <Move_S>(); //checing if the placemarker belongs to a plate/board/tray if (move != null) { for (int i = 0; i < food.Length; i++) { food[i].SetOnSurface(true); move.ListOfFood().Add(food[i]); //adding food to the surface accordingly } } i.OnPutDown(m, transform, false); } } }
public void SpwanObject() //function to spawn an object is required { if (surface != null) { GameObject obj = Instantiate(surface, transform.position, Quaternion.identity); Move_S s = obj.GetComponentInChildren <Move_S>(); if (s != null) { s.SetMarker(this); } SetOccupation(true); if (surface.CompareTag("Plate")) { PlateStock plateStock = GetComponentInParent <PlateStock>(); plateStock.PlateList().Add(s); obj.transform.SetParent(transform.parent); } } }
public IEnumerator GetWaiter(Transform toPos, Move_S plate) //routine to dictate the path and movement of the waiter { while (inProgress) { yield return(null); } inProgress = true; GameObject instance = Instantiate(waiter, start.position, new Quaternion(0, 180, 0, 0)); //new gameobject each time, quick way to revert to deafault transforms agent = instance.GetComponent <NavMeshAgent>(); //using navmesh agent to dictate the movemnt of the waiter plateSlot = instance.transform.Find("PlateSlot"); shoulder = instance.transform.Find("ArmNShoulder"); StartCoroutine(DoorMovement(Vector3.up, 120, 1)); yield return(StartCoroutine(MoveWaiter(toPos, plate, instance))); inProgress = false; }
public void SendMeal(List <Food_O> food, MealTicket ticket, Move_S plate) //when the player puts plate on send area { MealAssessment assessment = new MealAssessment(food, ticket, menu, mealsThrough); //meal assessment ticket.pauseTimer = true; assessment.AssessMeal(); double moneyBack = assessment.Money(); //getting the money value StartCoroutine(UpdateMoney(moneyBack, moneyBack / 10d)); //updating credit daysEarnings += moneyBack; int mealIndex = mealTickets.IndexOf(ticket); mealTickets.Remove(mealTickets[mealIndex]); //removing from list so new meal can come through mealsThrough++; StartCoroutine(ShowResults(assessment)); //showing feedback StartCoroutine(waiter.GetWaiter(sendAreas[ticket.GetScreen().screenNo - 1].transform, plate)); //calling for the waiter mealAssesments.Add(assessment.AssessmentText()); DisallowInteraction(plate); }
void SurfaceFood(Transform t) //making sure all the food and the object behaves correctly { Move_S s = GetHolding().GetObject().GetComponent <Move_S>(); List <Food_O> foodList = s.ListOfFood(); if (foodList.Count > 0) { List <Food_O> children = new List <Food_O>(); for (int i = 0; i < foodList.Count; i++) { if (foodList[i].HasChild()) { //need to link child with parent foodList[i].GetChild().EnablePhysics(foodList[i].transform); //setting transform to parent food children.Add(foodList[i].GetChild()); } if (!children.Contains(foodList[i])) { foodList[i].EnablePhysics(s.transform); } } } s.EnablePhysics(t); }