Hey guys sooo i ran into a error when i tried playing my game
THIS HAPPENS WHEN I TYPE 1 OR 2
Here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hacker : MonoBehaviour
{
// Game configriation data
string[] Level1Passwords = { "items", "spices", "Water", "waiter", "food" };
string[] Level2Passwords = { "credit", "money", "transfer", "account", "balance" };
//Game Stats
int level;
string Password;
enum Screen { MainMenu, Password, Win }
Screen currentscreen;
// Use this for initialization
void Start()
{
ShowMenuscreen();
}
void ShowMenuscreen()
{
currentscreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("");
Terminal.WriteLine("WHERE WOULD U LIKE TO HACK TODAY");
Terminal.WriteLine("");
Terminal.WriteLine("Press 1 to hack into a restarunt");
Terminal.WriteLine("Press 1 to hack into an ATM");
Terminal.WriteLine("");
Terminal.WriteLine("ENTER YOUR SELECTION HERE -");
}
void OnUserInput(string input)
{
if (input == "menu")
{
ShowMenuscreen();
}
else if (currentscreen == Screen.MainMenu)
{
Runmainmenu(input);
}
else if (currentscreen == Screen.Password)
{
CheckPassword(input);
}
}
void Runmainmenu(string input)
{
bool Isvalidnumber = (input == "1" || input == "2");
if (Isvalidnumber)
{
int.Parse(input);
Startgame();
}
else if (input == "menu")
{
ShowMenuscreen();
}
else
{
Terminal.WriteLine("Error chose a valid operation");
}
}
void Startgame()
{
currentscreen = Screen.Password;
Terminal.ClearScreen();
switch (level)
{
case 1:
Password = Level1Passwords[Random.Range(0, Level1Passwords.Length)];
Debug.Log(Password);
break;
case 2:
Password = Level2Passwords[Random.Range(0, Level2Passwords.Length)];
break;
default:
Debug.LogError("Error u have chosen a invalid level");
break;
}
Terminal.WriteLine("Waiting for a password");
}
void CheckPassword(string Input)
{
if (Input == Password)
{
Displaywinscreen(); ;
}
else
{
Terminal.WriteLine("Wrong password try again");
}
}
void Displaywinscreen()
{
currentscreen = Screen.Win;
Terminal.ClearScreen();
ShowWellDone();
}
void ShowWellDone()
{
switch (level)
{
case 1:
Terminal.WriteLine("Have a slice plsss...");
Terminal.WriteLine(@"
___
| ~~--.
|%=@%%/
|o%%%/
__ |%%o/
_,--~~ | |(_/ ._
,/' m%%%%| |o/ / `\.
/' m%%o(_)%| |/ /o%%m `\
/' %%@=%o%%%o| /(_)o%%% `\
/ %o%%%%%=@%%| /%%o%%@=%% \
| (_)%(_)%%o%%| /%%%=@(_)%%% |
| %%o%%%%o%%%(_|/%o%%o%%%%o%%% |
| %%o%(_)%%%%%o%(_)%%%o%%o%o%% |
| (_)%%=@%(_)%o%o%%(_)%o(_)% |
\ ~%%o%%%%%o%o%=@%%o%%@%%o%~ /
\. ~o%%(_)%%%o%(_)%%(_)o~ ,/
\_ ~o%=@%(_)%o%%(_)%~ _/
`\_~~o%%%o%%%%%~~_/'
`--..____,,--'
");
break;
}
}
}