Game Development Reference
In-Depth Information
Listing 8-16. Converting a String to an AIVehicleObjectsAffected Enumeration
static AIVehicleObjectsAffected MatchObjectsAffected(String ObjectsAffectedStr)
{
AIVehicleObjectsAffected ObjectsAffected = AIVehicleObjectsAffected.None;
if (ObjectsAffectedStr.equalsIgnoreCase("None"))
{
ObjectsAffected = AIVehicleObjectsAffected.None;
}
else
if (ObjectsAffectedStr.equalsIgnoreCase("WayPoints"))
{
ObjectsAffected = AIVehicleObjectsAffected.WayPoints;
}
else
if (ObjectsAffectedStr.equalsIgnoreCase("PrimaryWeapon"))
{
ObjectsAffected = AIVehicleObjectsAffected.PrimaryWeapon;
}
else
if (ObjectsAffectedStr.equalsIgnoreCase("SecondaryWeapon"))
{
ObjectsAffected = AIVehicleObjectsAffected.SecondaryWeapon;
}
return ObjectsAffected;
}
The LoadState() function loads data from a shared preferences entry into the class member
variables.
The LoadState() function does the following:
1.
Gets the shared preferences object associated with the input parameter
Handle.
2.
Loads data for each of the class member variables. The general format for
doing this follows:
a.
Create the handle specific to that class member variable by concatenating the input
Handle parameter and the string identifier for that variable.
b. Read in the data using this new handle created in step 1.
c.
If necessary, convert the data into a data type that can be stored in that class
member variable.
See Listing 8-17. In order to save space, the listing has been shortened. For the full code for this
chapter, please see the Source Code/Download area located on apress.com .
 
Search WWH ::




Custom Search