I’ve got the following code, and as a C# noob (one that really does want to learn), I am requesting help here.
I’ve set it up so that a random customer is created (male/female), and that customer wants a random meal and drink.
Now, I want the player to be able to click on ingredients to create that meal and drink.
So for example:
Omelette would be: eggs, meat (ham blocks) and cheese.
How can I set every meal to have specific ingredients and then ask the player to click them?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class RestaurantManager : MonoBehaviour {
public Text MealText;
public Text CustomerText;
public Text IngredientsText;
public Image MealImage;
public string[] Meals;
public string[] Drinks;
public string NextMeal;
[HideInInspector]
public static bool NewMeal;
[HideInInspector]
public static string Gender;
[HideInInspector]
public static float GenderNumber;
// Use this for initialization
void Start () {
NewMeal = false;
CustomerText.text = "";
MealText.text = "";
IngredientsText.text = "";
}
// Update is called once per frame
void Update () {
if (NewMeal == true) {
NextMeal = GetRandomMeal () + " and " + GetRandomDrink();
MealText.text = "Order: " + NextMeal;
CustomerText.text = "I want " + NextMeal + " please.";
NewMeal = false;
}
GenderNumber = UnityEngine.Random.value;
if (GenderNumber > 0.5) {
Gender = "Male";
} else if (GenderNumber <= 0.5) {
Gender = "Female";
}
if (Input.GetKeyDown (KeyCode.R)) {
NewMeal = true;
Destroy(GameObject.Find("Customer"));
}
}
public string GetRandomMeal()
{
return Meals[Random.Range(0, Meals.Length)];
}
public string GetRandomDrink()
{
return Drinks[Random.Range(0, Drinks.Length)];
}
}