In my midterm CYA game, you come across 2 staircases, left and right. You have the option to choose which one you go to, the right advancing you and the left (eventually) sending you back because it is blocked. I don't know how to get it to do that based on what I already have.
List<string> itemsList1 = new List<string>();
string input1;
string input2;
public FirstSteps()
{
Console.WriteLine("Unfortunately for us, we have to start at the bottom of the castle, unless you have a catapult or a grappling hook, but I don't suppose you have either of those do you.\n");
}
public void Populate()
{
contentArray1[0] = "See that key lying there? Think we should grab it?\n Type Yes or No.";
contentArray1[1] = "Really? You don't want to grab the key thats just sitting there? Your loss.";
contentArray1[2] = "Wow, isn't this a cliche. 2 staircases, the wrtiers really must be getting bored. Anyways, we going for the right or the left?\n Type Right or Left";
contentArray1[3] = "This staircase is blocked, try again";
contentArray1[4] = "Theres a chest up here, wonder if that key can open it, wanna try?\n Type Yes or No.";
contentArray1[5] = "You need the key to open the chest, duh.";
}
public void KeyEvent()
{
Console.WriteLine(contentArray1[0]);
input1 = Console.ReadLine();
input1 = input1.ToLower();
if (input1 == "yes")
{
Console.WriteLine("Right, probably a good idea.");
itemsList1.Add("dirty key");
}
else
{
Console.WriteLine(contentArray1[1]);
}
}
public void StepsEvent()
{
Console.WriteLine(contentArray1[2]);
input2 = Console.ReadLine();
input2 = input2.ToLower();
if (input2 == "left")
{
Console.WriteLine(contentArray1[3]);
}
if (input2 == "right")
{
Console.WriteLine("Right one it is.");
Console.WriteLine(contentArray1[4]);
}
}
This is (most of) my class that I am working with. When I begin working with input2 is where the problem arises, based on what I have set up with the array and the if statements I don't know how to make it so when the left if statemnt triggers, it says contentArray1[3], and then sends you back to the decision. I imagine I need a loop but I don't know where to put it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.