Esempio n. 1
0
        private void SomeoneWon(WhoScored whoScored)
        {
            isWinner = true;
            if (whoScored == WhoScored.FirstPlayer)
            {
                winnerText = "FIRST PLAYER WON";
            }
            else
            {
                winnerText = "SECOND PLAYER WON";
            }

            firstPlayer.Score  = 0;
            secondPlayer.Score = 0;
        }
Esempio n. 2
0
 public void Stop(WhoScored whoScored)
 {
     this.whoScored = whoScored;
     if (whoScored == WhoScored.FirstPlayer)
     {
         firstPlayer.Score++;
         SetStartingPositions();
         play = false;
     }
     else if (whoScored == WhoScored.SecondPlayer)
     {
         secondPlayer.Score++;
         SetStartingPositions();
         play = false;
     }
     if (firstPlayer.Score == pointsToWin || secondPlayer.Score == pointsToWin)
     {
         SomeoneWon(whoScored);
     }
 }
Esempio n. 3
0
        public void GenerateRandomStart(WhoScored whoScored)
        {
            Random random = new Random();

            if (whoScored == WhoScored.FirstPlayer)
            {
                ball.LeftRightValue = LeftRight.Left;
            }
            else if (whoScored == WhoScored.SecondPlayer)
            {
                ball.LeftRightValue = LeftRight.Right;
            }
            else
            {
                int left = random.Next(0, 2);
                if (left == 0)
                {
                    ball.LeftRightValue = LeftRight.Left;
                }
                else
                {
                    ball.LeftRightValue = LeftRight.Right;
                }
            }

            int up = random.Next(0, 2);

            if (up == 0)
            {
                ball.UpDownValue = UpDown.Up;
            }
            else
            {
                ball.UpDownValue = UpDown.Down;
            }

            ball.SpeedVertical   = random.Next(ball.SpeedVerticalMin, ball.SpeedVerticalMax + 1);
            ball.SpeedHorizontal = random.Next(ball.SpeedHorizontalMin, ball.SpeedHorizontalMax + 1);
        }