/// <summary> /// Updates the state of the game. This method checks the GameScreen.IsActive /// property, so the game will stop updating when the pause menu is active, /// or if you tab away to a different application. /// </summary> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, false); SpriteBatch spriteBatch = ScreenManager.SpriteBatch; // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) { pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1); } else { pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0); } if (IsActive) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { ScreenManager.AddScreen(new PhonePauseScreen(), ControllingPlayer); } TouchCollection touches = TouchPanel.GetState(); if (!bTouching && touches.Count > 0) { bTouching = true; TouchLocation touch = touches[0]; if (boardHandler.MenuPressed(touch, spriteBatch)) { ScreenManager.AddScreen(new PhonePauseScreen(), ControllingPlayer); } else { if (!boardHandler.InProgress) { boardHandler.Touch(touch, spriteBatch); } } } else if (touches.Count == 0) { bTouching = false; } if (boardHandler.InProgress && !boardHandler.Rotating()) { boardHandler.CauseChainReaction(); } else { if (boardHandler.GetScore == boardHandler.GetTargetScore) { //Add save score here string saveString = string.Format("{0},{1},{2}{3}", boardHandler.GetScore, boardHandler.Attempts, DateTime.Now.ToString(), Environment.NewLine); // Open a storage container. try { IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); // grab the storage FileStream stream; if (!store.FileExists(HIGHSCORE_FILE)) { stream = store.CreateFile(HIGHSCORE_FILE); } else { stream = store.OpenFile(HIGHSCORE_FILE, FileMode.Append); } StreamWriter writer = new StreamWriter(stream); writer.Write(saveString); writer.Close(); } catch (Exception ex) { } ScreenManager.AddScreen(new FinishGameScreen(boardHandler.GetScore, boardHandler.Attempts), ControllingPlayer); } } } }