예제 #1
0
        public RobotPongGame(
            Paddle leftPaddle,
            Paddle rightPaddle,
            Ball ball,
            RobotDifficultyOption difficulty = RobotDifficultyOption.Intermediate,
            bool isBotWithLeftPaddle         = true,
            int roundsToWinCount             = GlobalConstants.Gameplay.RoundsToWinCount,
            int framesPerSecond = GlobalConstants.Gameplay.FramesPerSecond)

            : base(leftPaddle, rightPaddle, ball, roundsToWinCount, framesPerSecond)
        {
            switch (difficulty)
            {
            case RobotDifficultyOption.Beginner:
                this.NumericDifficulty = 0.5;
                break;

            case RobotDifficultyOption.Intermediate:
                this.NumericDifficulty = 0.70;
                break;

            case RobotDifficultyOption.Expert:
                this.NumericDifficulty = 0.85;
                break;

            default:
                throw new NotSupportedException("Unsupported Bot Difficulty");
            }

            this.BotPaddle       = isBotWithLeftPaddle ? this.LeftPaddle : this.RightPaddle;
            this.PlayerPaddle    = isBotWithLeftPaddle ? this.RightPaddle : this.LeftPaddle;
            this.IsBotPaddleLeft = isBotWithLeftPaddle;
        }
예제 #2
0
        public static void Run()
        {
            while (true)
            {
                MainMenuOption mainMenuOption = MainMenu.New();

                if (mainMenuOption == MainMenuOption.TwoPlayerGame)
                {
                    var game = new TwoPlayerPongGame(NewLeftPaddle(), NewRightPaddle(), new Ball());
                    game.Start();
                }
                else if (mainMenuOption == MainMenuOption.AgainstBot)
                {
                    RobotDifficultyOption difficulty = RobotDifficultyMenu.New();
                    bool isBotWithLeftPaddle         = PlayerPaddleSideMenu.New() != PaddleSideOption.Left;
                    var  game = new RobotPongGame(NewLeftPaddle(), NewRightPaddle(), new Ball(), difficulty, isBotWithLeftPaddle);
                    game.Start();
                }
                else if (mainMenuOption == MainMenuOption.Exit)
                {
                    Environment.Exit(0);
                }
            }
        }