Game Development Reference
In-Depth Information
if(RouteInformation.ContainsKey(destination))
{
return RouteInformation[destination];
}
else
{
return null;
}
Shorter, neater, and much nicer, don't you think?
For more information, see the MSDN C# page at http://bit.ly/csharpconditionaloperator .
The script is very basic for now, but contains several following key elements that can be
expanded to meet the design goals of your game:
RouteInformation : This is a list of all the possible destinations in the game
in a dictionary.
◦ A static list of possible destinations in the game, and it is a core part of
the manager as it knows everywhere you can travel in the game in one
place.
GetRouteInfo : This is a basic information extraction function.
◦ A simple controlled function to interrogate the destination list. In this ex-
ample, we just return the text to be displayed in the prompt, which allows
for more detailed descriptions that we could use in tags. You could use
this to provide alternate prompts depending on what the player is carrying
and whether they have a lit torch, for example.
CanNavigate : This is a test to see if navigation is possible.
◦ If you are going to limit a player's travel, you need a way to test if they
can move, allowing logic in your game to make alternate choices if the
player cannot. You could use a different system for this by placing some
sort of block in front of a destination to limit choice (as used in the likes
of Zelda), such as an NPC or rock. As this is only an example, we can al-
ways travel and add logic to control it if you wish.
NavigateTo : This is a function to instigate navigation.
◦ Once a player can travel, you can control exactly what happens in the
game: does navigation cause the next scene to load straight away (as in
the script currently), or does the current scene fade out and then a travel-
Search WWH ::




Custom Search