computer.Score = int.Parse(Microsoft.Phone.Shell.PhoneApplicationService.Current.State["computerScore"].ToString());
isHumanTurn = !bool.Parse(Microsoft.Phone.Shell.PhoneApplicationService.Current.State["isHumanTurn"].ToString());
wind = Vector2.Zero;
changeTurn = true;
computer.Catapult.CurrentState = CatapultState.Reset;
// Start the game
Note the highlighted statements at the end of the function. Those statements utilize the Tombstoning capabilities to reload the application state, where the first highlighted statement checks if any state data is available.
This concludes the task.
Now our game is enriched with tombstoning and state reloading features.
Task 2 – Utilize Chooser and Launcher to run another application from the game
As we already mentioned, we use Choosers and Launchers to launch another application from our game. The difference between Choosers and Launchers is that Choosers provide results back to the game, while Launchers do not. The development platform provides a rich collection of Choosers and Launchers that launch standard Windows Phone tasks out-of-the box. In this exercise, we will use a Chooser of type PhoneNumberChooserTask and a Launcher of type SmsComposeTask.
PhoneNumberChooserTask launches the standard Phone Book application and returns the selected number back to the game.
SmsComposeTask sends SMS to the given number.
In this task, we will integrate two those capabilities into our game.
Open file MainMenuScreen.cs located in “Screens” folder.
Locate the “Using Statements” region and add there the following statement:
This statement allows using Choosers and Launchers.
Page | 99