I'm trying to make a text-based dungeon explorer in C#
, and I have the maze-part all working. I used some methods that refer to each other when you pick a direction you want to go in.
The "map" is divided in 13 rooms total. This is an example for when you leave the starting room .
Console.WriteLine("REMEMBER! You are always looking north when deciding which room you go in.");
Console.WriteLine("one room goes right in front of you, one goes behind you, another one goes to the right and the third one goes straight in front of you.");
Console.WriteLine("if you want to give up, type 'give up'");
Console.WriteLine("which way do you go?");
choice = Console.ReadLine().ToLower();
while (choice != "behind" && choice != "right" && choice != "in front" && choice != "give up")
{
Console.WriteLine("you cant stay here, can you?");
Console.WriteLine("Type: 'behind', 'right' of 'in front' to move in a specific direction.");
choice = Console.ReadLine().ToLower();
}
switch (choice)
{
case "in front":
Console.Clear();
room1();
break;
case "behind":
Console.Clear();
room11();
break;
case "right":
Console.Clear();
room7();
break;
}
And this is the maze itself:
Just a maze is fun, but I would like there to be an element of surprise. I was thinking of putting a monster in room 8, for example. The monster doesn't have to be there every game. At the beginning of the game, I would like to define a variable that decides if there is going to be a monster or not (I was planning on doing this with an array and a random number so it would be 50/50 chance). The problem is to keep the variable, so it doesn't change every time you move to a different room.
Does anyone know how I can define a variable (or maybe something else that I don't know? I'm somewhat new to programming in multiple methods) at the beginning of the game to determine if there is a monster or not? I have tried working with various classes, but I have never done this before, so I don't know how I can work in different classes in de same namespace.
I will also further use this to determine in what room the sword to slay the monster is in and in what room the key to the escape door is etc.