- Home /
Question by
Danielcool20 · Nov 24, 2019 at 07:19 AM ·
index
Problem with indexing
I want to make sure that the user can input "Take cereal", Take milk" and 'Take bowl" at any order and after inputting all three you can input "Pour milk into bowl". I want to know if it is possible to do this with indexing and if there is an alternative way to do this.
string[] commands = new string[] {"Take cereal","Take milk","Take bowl", "Pour milk into bowl"};
int currentCommand = 0;
public void OnSubmit()
{
{
WordInput = nameField.text;
if (WordInput.ToLower() == commands[currentCommand])
{
currentScene = currentCommand;
//background.current_image.sprite = background.stockimages[sceneElements[currentScene].background_image];
//fruit.current_image.sprite = fruit.stockimages[sceneElements[currentScene].fruit_image];
}
if (currentCommand >= 0)
{
currentScene = currentCommand;
GameObject.Find("Cereal").SetActive(false);
CerealInvent.SetActive(true);
currentCommand++;
}
if (currentCommand >= 0)
{
currentScene = currentCommand;
GameObject.Find("milk").SetActive(false);
MilkInvent.SetActive(true);
currentCommand++;
}
if (currentCommand >= 0)
{
currentScene = currentCommand;
GameObject.Find("Bowl").SetActive(false);
BowlInvent.SetActive(true);
currentCommand++;
}
if (currentCommand == 4)
{
CerealInvent.SetActive(false);
BowlInvent.SetActive(false);
MilkInvent.SetActive(false);
MilkinBowl.SetActive(true);
}
if ("Kill myself" == WordInput) {
Application.Quit();
}
else
{
print("Hell Yeah");
}
}
Comment