Exemplo n.º 1
0
 /// <summary>
 /// Event handler for when the Concede Game menu entry is selected.
 /// </summary>
 void ConcedeGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     const string message = "Concede this game?";
     MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);
     confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
     ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
 }
Exemplo n.º 2
0
        public override void HandleInput(InputState input)
        {
            String Message = "";
            if (input == null)
                throw new ArgumentNullException("input");
            int playerIndex = (int)ControllingPlayer.Value;
            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];

            if (input.IsPauseGame(ControllingPlayer))
            {
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
            }
            else if (Player_1_Points >= mySettings.ScoreToWin)
            {
                AudioManager.PlayCue("Music_Win");
                if (!mySettings.QuickPlay)
                {
                    //Update Player Information
                    myPlayers.myPlayers[0].Won();
                    myPlayers.myPlayers[1].Lost();
                    myPlayersXML.Save(myPlayers);
                    Message = myPlayers.myPlayers[0].UserName + " Win!";
                    //Update Game History
                    Class_Library.Game myGame = new Class_Library.Game();
                    myGame.GameID = myGameList.GetLastID() + 1;
                    myGame.Player1_Name = myPlayers.myPlayers[0].UserName;
                    myGame.Player2_Name = myPlayers.myPlayers[1].UserName;
                    myGame.Player1_Score = Player_1_Points;
                    myGame.Player2_Score = Player_2_Points;
                    myGameList.AddItem(myGame);
                    myGameHistoryXML.Save(myGameList);

                    //New Code Added
                    myLatestSave.Player1_Name = myPlayers.myPlayers[0].UserName;
                    myLatestSave.Player2_Name = myPlayers.myPlayers[1].UserName;

                    myLatestSave.Player1_Score = Player_1_Points;
                    myLatestSave.Player2_Score = Player_2_Points;
                    myLatestSave.BallSpeed_X = BallPosition.XSpeedFactor;
                    myLatestSave.BallSpeed_Y = BallPosition.YSpeedFactor;
                    mySaveGameXML.Save(myLatestSave);
                }
                else
                {
                    Message = "Artificial Intelligence Beat you. Too Bad";
                }

                MessageBoxScreen WinningMessageBox = new MessageBoxScreen(Message, false);
                WinningMessageBox.Accepted += WinningMessageBoxAccepted;
                ScreenManager.AddScreen(WinningMessageBox, ControllingPlayer);
            }
            else if (Player_2_Points >= mySettings.ScoreToWin)
            {
                AudioManager.PlayCue("Music_Win");
                if (!mySettings.QuickPlay)
                {
                    TimeSpan GameDuration = new TimeSpan();
                    GameDuration = DateTime.Now - myGameTime;

                    myPlayers.myPlayers[0].Lost();
                    myPlayers.myPlayers[1].Won();
                    myPlayersXML.Save(myPlayers);
                    Message = myPlayers.myPlayers[1].UserName + " Win!";

                    Class_Library.Game myGame = new Class_Library.Game();
                    myGame.GameID = myGameList.GetLastID() +1;
                    myGame.Player1_Name = myPlayers.myPlayers[0].UserName;
                    myGame.Player2_Name = myPlayers.myPlayers[1].UserName;
                    myGame.Player1_Score = Player_1_Points;
                    myGame.Player2_Score = Player_2_Points;
                    myGame.TimeDuration = Convert.ToInt32(GameDuration.TotalSeconds);
                    myGameList.AddItem(myGame);
                    myGameHistoryXML.Save(myGameList);

                    //New Code Added
                    myLatestSave.Player1_Name = myPlayers.myPlayers[0].UserName;
                    myLatestSave.Player2_Name = myPlayers.myPlayers[1].UserName;

                    myLatestSave.Player1_Score = Player_1_Points;
                    myLatestSave.Player2_Score = Player_2_Points;
                    myLatestSave.BallSpeed_X = BallPosition.XSpeedFactor;
                    myLatestSave.BallSpeed_Y = BallPosition.YSpeedFactor;
                    mySaveGameXML.Save(myLatestSave);
                }
                else
                {
                    Message = "Congratulations, you Beat the Computer";
                }

                MessageBoxScreen WinningMessageBox = new MessageBoxScreen(Message, false);
                WinningMessageBox.Accepted += WinningMessageBoxAccepted;
                ScreenManager.AddScreen(WinningMessageBox, ControllingPlayer);
            }
            else
            {
                //determine how fast the paddle will move
                if (keyboardState.IsKeyDown(Keys.Up))
                    RightPaddlePosition.MoveDown();
                if (keyboardState.IsKeyDown(Keys.Down))
                    RightPaddlePosition.MoveUp();

                if (mySettings.QuickPlay)
                {
                    int temp = (int)BallPosition.YSpeedFactor;
                    if (temp > 5)
                        temp = 5;
                    LeftPaddlePosition.movefactor = temp;

                    if (BallPosition.Y > LeftPaddlePosition.Y)
                        LeftPaddlePosition.MoveUp();
                    else if (BallPosition.Y < LeftPaddlePosition.Y)
                        LeftPaddlePosition.MoveDown();
                }
                else
                {
                    if (keyboardState.IsKeyDown(Keys.W))
                        LeftPaddlePosition.MoveDown();
                    if (keyboardState.IsKeyDown(Keys.S))
                        LeftPaddlePosition.MoveUp();
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Event handler for when the Save Game menu entry is selected.
 /// </summary>
 void SaveGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     const string message = "Save Current Game?";
     MessageBoxScreen confirmSaveMessageBox = new MessageBoxScreen(message);
     confirmSaveMessageBox.Accepted += confirmSaveMessageBoxAccepted;
     ScreenManager.AddScreen(confirmSaveMessageBox, ControllingPlayer);
 }