public bool checkOrders(IFood food) { int bestMatch = -1; for (int i = 0; i < tickets.Length; i++) { //if already found an order thats been waiting longer keep that one if (tickets[i] == null || food.GetType() != tickets[i].getFood().GetType() || (bestMatch != -1 && tickets[bestMatch].getStartTime() < tickets[i].getStartTime())) { continue; } if (food.Compare(tickets[i].getFood())) { bestMatch = i; } } if (bestMatch != -1) { StartCoroutine(myGame.finishOrder(tickets[bestMatch].getTimeSpent())); deleteTicket(bestMatch); return(true); } else { StartCoroutine(myGame.failOrder()); return(false); } }