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()); }
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); }
public void AssessMeal() //probably need splitting up, but accesses meal { double mealPrice = men.GetMealPrice(_ticket.GetMealName()); bool noMoneyBack = false; int badPoints = 0;//plus and minus system, needs refining int goodPoints = 0; text = "#" + (mealsSent + 1).ToString() + " " + _ticket.GetMealName() + "\n\n"; List <string> foodNames = new List <string>(); foreach (Food_O f in food) { foodNames.Add(f.GetName()); bool needCook = CheckIfCook(f.GetName()); //checking if need cooking if (f.FoodCooked() && needCook) { int factor = f.GetCookFactor(); //checking how cooked the food is switch (factor) { case -1: text += f.GetName() + " is Undercooked \n"; badPoints++; break; case 0: text += f.GetName() + " is Perfectly Cooked \n"; goodPoints++; break; case 1: text += f.GetName() + " is Overcooked \n"; badPoints++; break; case 2: text += f.GetName() + " is Burnt \n"; badPoints += 2; break; } } else if (f.FoodCooked() && !needCook) { text += f.GetName() + " did not need cooking \n "; badPoints++; } else if (!f.FoodCooked() && needCook) { text += f.GetName() + " is Raw \n "; noMoneyBack = true; } } for (int i = 0; i < _ticket.TheFoodInOrder().Count; i++) { if (_ticket.TheFoodInOrder()[i].Contains(" -c")) { _ticket.TheFoodInOrder()[i] = _ticket.TheFoodInOrder()[i].Replace(" -c", ""); } } bool goodLook = CheckPresenation(foodNames, _ticket.TheFoodInOrder(), food); Dictionary <string, int> fromPlate = CheckAndSortFood(foodNames); // Dictionary <string, int> fromMenu = CheckAndSortFood(_ticket.TheFoodInOrder()); foreach (KeyValuePair <string, int> entry in fromPlate) { if (!fromMenu.ContainsKey(entry.Key)) { text += "Wrong food " + entry.Key + "\n"; badPoints++; } } foreach (KeyValuePair <string, int> entry in fromMenu) { if (fromPlate.Contains(entry)) { text += "Correct food and amount " + entry + "\n"; goodPoints++; //4 } if (fromPlate.ContainsKey(entry.Key) && !fromPlate.ContainsValue(entry.Value)) { int plateVal = 0; fromPlate.TryGetValue(entry.Key, out plateVal); int differece = entry.Value - plateVal; if (differece < 0) { differece *= -1; text += "There are " + differece + " to many " + entry.Key + "'s" + "\n"; badPoints++; } else { text += "You needed " + differece + " more " + entry.Key + "\n"; badPoints++; } } else if (!fromPlate.Contains(entry)) { text += "Meal is missing " + entry.Value + " " + entry.Key + "\n"; badPoints += 2; //no money back } } float time = _ticket.GetTicketTime(); bool customerLeft = false; if (time > 180) { customerLeft = true; } if (customerLeft) { money = 0; text += CustomerResponses(4, time); customerLeft = false; } else if (noMoneyBack) { money = 0; text += CustomerResponses(0, time); noMoneyBack = false; } else if (badPoints == 0) { if (!goodLook) { money = System.Math.Round(mealPrice / 1.25, 2); text += CustomerResponses(5, time); } else { money = mealPrice + (mealPrice / System.Math.Round(Random.Range(5f, 15f), 2)); text += CustomerResponses(1, time); } } else if (badPoints > goodPoints) { money = 0; text += CustomerResponses(0, time); } else if (goodPoints > badPoints) { if (!goodLook) { money = System.Math.Round(mealPrice / 2, 2); text += CustomerResponses(6, time); } else { money = mealPrice; text += CustomerResponses(3, time); } } else if (goodPoints == badPoints) { money = System.Math.Round(mealPrice / 2, 2); text = CustomerResponses(2, time); } food.Clear(); _ticket.TheFoodInOrder().Clear(); _ticket.GetScreen().SetUse(false); _ticket.GetScreen().GetText().text = "Order #" + _ticket.GetScreen().screenNo.ToString(); }