I wanted to know if there was an easier or faster method for what I'm doing. The map is not linear which is why I thought of making the variables all different. And I want the map to show the room only if the player has been there. So maybe they could go all left and miss all of the rooms from 8-12, but go to rooms 8,13, and 14. Does anyone know any method for this?
Not all code is included but this is the gist of it.
int MapF101 = 1;
int MapF102 = 0;
int MapF103 = 0;
int MapF104 = 0;
int MapF105 = 0;
int MapF106 = 0;
int MapF107 = 0;
int MapF108 = 0;
int MapF109 = 0;
int MapF110 = 0;
int MapF111 = 0;
int MapF112 = 0;
int MapF113 = 0;
int MapF114 = 0;
int MapF115 = 0;
if (command == "Forward")
{
if (room <= 15 && floor == 1)
{
Console.WriteLine("Where are you trying to go?");
}
else if (room <= 27 && floor == 2)
{
Console.WriteLine("Where are you trying to go?");
}
else
{
if (room == 1 && floor == 1 && Direction == 1)
{
room = 2;
MapF102 = 1;
}
else
{
Console.WriteLine("You ran into a wall");
}
}
goto wannado;
}
if (command == "Map")
{
if (MapF101 == 1)
{
Console.WriteLine("#####/n# #/n#####");
}
if (MapF102 == 1)
{
Console.WriteLine("#####/n# #/n#####");
}
goto wannado;
}
It is better to use object for room. In this case all information is gathered in one place.
public class Room
{
public int Id { get; set; }
public bool Visited { get; set; }
}
Next step is to add possible exits from current room. You could use anything - North/East/South/West, Left/Rigth/Up/Down or smth else. This is more complex, but will let you to design any map :)
public class Room
{
public int Id { get; set; }
public string Name { get; set; }
public bool Visited { get; set; }
public Room North { get; set; }
public Room South { get; set; }
public Room East { get; set; }
public Room West { get; set; }
public Room(int id, string name)
{
Id = id;
Name = name;
}
}
You could create you map manually or load it from DB or file.
var entrance = new Room(1, "Entrance");
var room2 = new Room(2, "Room #2");
var room3 = new Room(3, "Room #3");
var room4 = new Room(4, "Room #4");
var room5 = new Room(5, "Room #5");
entrance.North = room5;
entrance.East = room2;
entrance.West = room3;