Example #1
0
        //Vector2 touchPos;
        protected override void UpdateScreen(GameTime gameTime, DisplayOrientation displayOrientation)
        {
            if (input.IsPressed(ActionTutorial))
            {
                changeScreenDelegate(ScreenState.Tutorial);
                displayTimer = 0;
            }

            if (input.IsPressed(ActionAbout))
            {
                displayTimer = 0;
                recordReset  = false;
                changeScreenDelegate(ScreenState.About);
            }

            if (MediaPlayer.GameHasControl && input.IsPressed(ActionMusic)) //game MUST have control in order to play music
            {
                //change music or turn it off.
                if (InGameMenu.trackNumber == 3)
                {
                    InGameMenu.trackNumber = -1;  //no music should play
                    MediaPlayer.Stop();
                    trackTitle = "Nothing";
                    InGameMenu.musicPlaying = false;
                }
                else if (InGameMenu.trackNumber < 0)
                {
                    InGameMenu.trackNumber = 0;    //start over
                    MediaPlayer.Play(InGameMenu.tracklist[InGameMenu.trackNumber]);
                    MediaPlayer.IsRepeating = true;
                    trackTitle = InGameMenu.tracklist[InGameMenu.trackNumber].Name.Substring(6);    //eliminates "Music/" from the name
                    InGameMenu.musicPlaying = true;
                }
                else
                {
                    InGameMenu.trackNumber++;
                    MediaPlayer.Play(InGameMenu.tracklist[InGameMenu.trackNumber]);
                    MediaPlayer.IsRepeating = true;
                    trackTitle = InGameMenu.tracklist[InGameMenu.trackNumber].Name.Substring(6);
                    InGameMenu.musicPlaying = true;
                }

                //save settings
                InGameMenu.UpdateTrackFile();

                //set display timer
                displayTimer = 60;
            }

            if (!recordReset && input.IsPressed(ActionDelete))
            {
                //reset record
                recordReset = true;
                soundEffects.PlaySound("SoundEffects/Win");
                InGameMenu.CreateRecord();
            }


            if (input.IsPressed(ActionExit) || BackButtonPressed())
            {
                recordReset  = false;
                displayTimer = 0;
                changeScreenDelegate(ScreenState.InGameMenu);
            }

            //update timer
            displayTimer--;
            if (displayTimer < 0)
            {
                displayTimer = 0;
            }

            //update background
            background.Position.X     += 2;
            backgroundCopy.Position.X += 2;

            if (background.Position.X > windowWidth)
            {
                background.Position.X = -windowWidth + 2;   //2 is added to eliminate gap between images.
            }
            if (backgroundCopy.Position.X > windowWidth)
            {
                backgroundCopy.Position.X = -windowWidth + 2;
            }
        }
Example #2
0
        protected override void UpdateScreen(GameTime gameTime, DisplayOrientation displayOrientation)
        {
            if (!levelLoaded)
            {
                //load level
                LoadLevel(LevelSelect.level);
                /***INSERT CODE FOR LOADING CURRENT ELAPSED TIME & TURN COUNT ***/
                LoadRecords();
                levelLoaded = true;
                RevertLevel();
                level.UpdateTileCount();
            }

            //play game until either condition is met
            if (!level.LevelComplete() && !level.LevelFailed())
            {
                level.Play();
                clock.Tick();
            }
            else if (level.LevelComplete())
            {
                if (!soundPlaying)
                {
                    soundEffects.PlaySound("SoundEffects/Win");
                    soundPlaying = true;
                }
            }
            else if (level.LevelFailed())
            {
                if (!soundPlaying)
                {
                    soundEffects.PlaySound("SoundEffects/Lose");
                    soundPlaying = true;
                }
            }

            //update music display timer
            displayTimer--;
            if (displayTimer < 0)
            {
                displayTimer = 0;
            }


            if (input.IsPressed(ActionQuit) || BackButtonPressed())
            {
                //go back to level select screen

                //if the level's not complete and it's not game over, then it's a ragequit.
                //If the player presses the Back button, then it doesn't count.
                if (!level.LevelComplete() && !level.LevelFailed())
                {
                    InGameMenu.rageCount++;
                }

                //if player lost, record the loss
                if (level.LevelFailed())
                {
                    InGameMenu.lossCount++;
                }

                /***INSERT CODE FOR SAVING CURRENT ELAPSED TIME, TOTAL TURN COUNT ***/
                UpdateRecord();

                levelLoaded  = false;
                soundPlaying = false;
                changeScreenDelegate(ScreenState.LevelSelect);
            }

            if (input.IsPressed(ActionTutorial))
            {
                //open up the tutorial screen
                //soundEffects.PlaySound("SoundEffects/Select");
                changeScreenDelegate(ScreenState.Tutorial);
            }

            if (MediaPlayer.GameHasControl && input.IsPressed(ActionMusic))
            {
                //change music
                if (InGameMenu.trackNumber == 3)
                {
                    InGameMenu.trackNumber = -1;  //no music should play
                    MediaPlayer.Stop();
                    trackTitle = "Nothing";
                    InGameMenu.musicPlaying = false;
                }
                else if (InGameMenu.trackNumber < 0)
                {
                    InGameMenu.trackNumber = 0;    //start over
                    MediaPlayer.Play(InGameMenu.tracklist[InGameMenu.trackNumber]);
                    MediaPlayer.IsRepeating = true;
                    trackTitle = InGameMenu.tracklist[InGameMenu.trackNumber].Name.Substring(6);    //eliminates "Music/" from the name
                    InGameMenu.musicPlaying = true;
                }
                else
                {
                    InGameMenu.trackNumber++;
                    MediaPlayer.Play(InGameMenu.tracklist[InGameMenu.trackNumber]);
                    MediaPlayer.IsRepeating = true;
                    trackTitle = InGameMenu.tracklist[InGameMenu.trackNumber].Name.Substring(6);
                    InGameMenu.musicPlaying = true;
                }

                //save settings
                InGameMenu.UpdateTrackFile();

                //set display timer
                displayTimer = 60;
            }

            //update background
            background.Position.X     += 2;
            backgroundCopy.Position.X += 2;

            if (background.Position.X > windowWidth)
            {
                background.Position.X = -windowWidth + 2;   //2 is added to eliminate gap between images.
            }
            if (backgroundCopy.Position.X > windowWidth)
            {
                backgroundCopy.Position.X = -windowWidth + 2;
            }
        }