I have a quick question to assigning values.
In my new program I am trying to assign values to booleans depending on the value of an integer. Here a quick example of what I mean:
bool northDoorAvailable;
int roomLocation;
// set player Location in some code
roomLocation = 2;
// now set if the north door is available
Is this only possible with a function in that I write alot of if-statements?
public void checkDoors()
{
if ( roomLocation == 1 )
{
northDoorAvailable = false;
}
if ( roomLocation == 2 )
{
northDoorAvailable = true;
}
}
or can this process be automized?
Glad for any replies.
northDoorAvailable = roomLocation != 1;for example.roomlocation == 3?roomlocation != possibleLocationsit would donorthDoorAvailable = falsecheckDoorsfunction with that, but this is assuming thatnorthDoorAvailableis true only if the room location is not equal to 1. If you have other requirements, then its better to use a dictionary. I will type an answer that shows how you can use it.