/// <summary> /// WHEN THE BACK BUTTON IS PRESSED, WE WANT TO PAUSE THE GAME AND NAVIGATE /// BACK TO THE MENU PAGE: /// </summary> protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { userTimer.Stop(); GameHelper.PauseGame(true); NavigationService.Navigate(new Uri("/Pages/Menu.xaml", UriKind.Relative)); }
void sbGame_Completed(object sender, EventArgs e) { Storyboard sb = (Storyboard)sender; sb.Stop(); // did the user tap a rectangle or are we currently // displaying the sequence to them? if (Globals.bCurrentlyDisplayingSequence == true) { // we're currently displaying the sequence to the user if (Globals.iCurrentlyDisplayingSequenceIndex < Globals.currentSequence.Count - 1) { // not done yet! Globals.iCurrentlyDisplayingSequenceIndex += 1; DisplayRectangle(Globals.iCurrentlyDisplayingSequenceIndex, true); } else { // done! Globals.bCurrentlyDisplayingSequence = false; //re-enable the rectangles: EnableRectangles(); // when resuming the game after it was paused, // we don't want to display another random rectangle, // because we need the user to complete THIS sequence first if (Globals.bJustResumedGame == false) { // now add a random on to the list: ShowNextRandomRect(); } else { // since we aren't calling ShowNextRandomRect, // we need to restart the user-wait timer manually: //Globals.waitForUserTimer.Start(); Globals.bJustResumedGame = false; } } } else { // should only hit here after we show them the VERY FIRST rectangle // now we are going to wait for the user to match the sequence! if (Globals.Data.YourTurnHelper == true && Globals.currentSequence.Count == 1) { // THE USER IS DONE, DISPLAY THE NEW SEQUENCE: // If the user hits back during the 3-2-1 countdown, the game will be paused before // execution gets here. We don't want to re-pause here because false is passed in // which causes the sequence to not be shown upon resume. if (Globals.bGameIsPaused == false) { GameHelper.PauseGame(false); ShowYourTurnMessage(); } } else { // WE WILL GET HERE EACH TIME AFTER THE "NEWEST" RANDOM RECT IS SHOWN: userTimer.Start(); //re-enable the rectangles: EnableRectangles(); //reset our user sequence: Globals.userTapSequence = new List <int>(); } } }