IEnumerator eatFood() { yield return(new WaitForSeconds(eatSpeed)); amountSpent += food.sellPrice; calculateSatisfaction(); fullness += 5; readyToOrder = true; wantsToStay = checkWantsToStay(); food = null; //setFoodSprite(); foodHolder.GetComponent <SpriteRenderer>().sprite = null; yield return(new WaitForSeconds(2.0f)); }
public void orderDish() { food = checkMenu(); if (!food.canBeMade()) { wantsToStay = false; Debug.Log("The kitchen is out of ingredients for the food they want!"); } else { Debug.Log("Food ordered!"); readyToOrder = false; food.orderDish(); setFoodSprite(); StartCoroutine(eatFood()); } }
private DishManager.Dish checkMenu() { List <DishManager.Dish> menuItems = DishManager.control.getMenuItems(); List <DishManager.Dish> potentialChoices = new List <DishManager.Dish>(); DishManager.Dish finalChoice = null; int randomNumber; //Check conditions for picking a dish foreach (DishManager.Dish dish in menuItems) { bool wouldPick = false; //Is it a preferred food type? if (dish.resourceType1 == preferredFoodType || dish.resourceType2 == preferredFoodType) { wouldPick = true; } //Is it good enough quality? if (dish.quality >= qualityThreshold) { wouldPick = true; } if (wouldPick) { potentialChoices.Add(dish); } } randomNumber = (int)Random.Range(1, 101); if (potentialChoices.Count > 0) { finalChoice = potentialChoices[randomNumber % potentialChoices.Count]; } else { wantsToStay = false; Debug.Log("Customer didn't see anything they like!"); } return(finalChoice); }