Пример #1
0
        /// <summary>
        /// Set whether the player has won, lost, or not yet.
        /// </summary>
        /// <param name="s"></param>
        public void SetState(WinLoseState s)
        {
            currWinLoseState = s;
            switch (currWinLoseState)
            {
            case WinLoseState.Win:
                UIText.Text  = Constants.WinText;
                UIText.Color = Color.Green;

                break;

            case WinLoseState.Lose:
                UIText.Text  = Constants.LoseText;
                UIText.Color = Color.Red;
                break;

            case WinLoseState.None:
                UIText.Text = String.Empty;

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(s), s, null);
            }
        }
Пример #2
0
 private void UpdateMainGame(GameTime gameTime)
 {
     switch (winLoseState)
       {
     case WinLoseState.Win:
     case WinLoseState.Lose:
       while (TouchPanel.IsGestureAvailable)
       {
     var gs = TouchPanel.ReadGesture();
     if (gs.GestureType == GestureType.Tap)
     {
       gameState = new GameState(gameState.difficulty);
       winLoseState = WinLoseState.None;
       SaveGameState();
     }
       }
       try
       {
     if (IS.FileExists(savePath))
       IS.DeleteFile(savePath);
       }
       catch (Exception)
       {
       }
       if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
       if (Back != null)
       {
           drawEnable = false;
           Back();
       }
       break;
     case WinLoseState.None:
       gameState.UpdateTime(gameTime, renderingState);
       gameState.UpdateInput(renderingState, gameTime);
       //winLoseState = gameState.UpdateBlocks(gameTime, renderingState, random);
       if (winLoseState != WinLoseState.None)
       {
     HighScores.AddScore(gameState.difficulty, new HighScore()
     {
       timeStamp = DateTime.Now,
       score = gameState.score
     });
       }
       if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
       {
     this.Enabled = false;
     drawEnable = false;
     Guide.BeginShowMessageBox(Strings.ConfirmExit, Strings.ConfirmExitMessage,
       new[] { Strings.Yes, Strings.No }, 0, MessageBoxIcon.Alert, new AsyncCallback(result =>
       {
         var dialogResult = Guide.EndShowMessageBox(result);
         this.Enabled = true;
         if (dialogResult.HasValue && dialogResult.Value == 0)
         {
             if (Back != null)
             {
                 SaveGameState();
                 Back();
             }
         }
         else
             drawEnable = true;
       }), null);
       }
       break;
       }
 }