Game Development Reference
In-Depth Information
break;
}
If a duplicate is not found, we add this token to the list as shown in
the following code:
if (uniqueToken)
{
missionTokens.add(mt);
}
Validate(mission) : This method will compare currentToken
set to a specific mission. If it has been found to have been satisfied,
the system is notified. To do this, we will use a search pattern similar
to the one used in the Add() method and start by assuming the mis-
sion is complete; only this time we will use a double-nested loop! This
is because to validate a mission means to search, individually, for
each token in the current mission against all of the tokens the user
has collected so far. This is done as shown in the following code:
bool missionComplete = true;
for (intinti = 0; I <
m.tokens.Count; i++)
{
bool tokenFound = false;
for (int j = 0; j <
missionTokens.count ; j++)
{
// if tokens match, tokenFound =
true
}
}
By assuming the token will not be found initially, we are required to
search for a matching token ID. If we don't find it, it automatically
means that the mission cannot be complete, and we don't have to
process any more comparisons, as shown in the following code:
Search WWH ::




Custom Search