Esempio n. 1
0
        bool Deactivated()
        {
            if (Globals.bDeactivated == true)
            {
                // RESET:
                Globals.bDeactivated = false;

                // DISABLE RECTANGLES FROM BEING TAPPED:
                DisableRectangles();

                // PAUSE THE GAME:
                GameHelper.PauseGame(true);

                // SHOW THE PAUSE GRID:
                ShowPauseGrid();

                // RETURN THAT THE GAME IS/WAS DEACTIVATED:
                return(true);
            }
            else
            {
                // GAME HAS NOT BEEN DEACTIVATED:
                return(false);
            }
        }
Esempio n. 2
0
        // Code to execute when the application is deactivated (sent to background)
        // This code will not execute when the application is closing
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            // THIS WILL LET US KNOW LATER ON, IF RE-ACTIVATED
            // THAT WE NEED TO SHOW THE PAUSE GRID:
            Globals.bDeactivated = true;
            //Globals.bCancel = true;

            if (Globals.bGameIsStarted)
            {
                GameHelper.PauseGame(true);
            }
        }
Esempio n. 3
0
 /// <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));
 }
Esempio n. 4
0
        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>();
                }
            }
        }