示例#1
0
        public static Paddle CreatePaddle(Game game
            , Paddle.Type type
            , Texture2D paddleTexture
            , Texture2D paddleActiveTexture
            , SoundEffect paddleSound
            , float width
            , float height
            )
        {
            float sensitivity = 2.5f;
            float halfWidth = width /2;
            float halfHeight = height /2;
            float paddleWidth = width / 10;
            float halfPaddleWidth = paddleWidth / 2;

            switch (type)
            {
                case Paddle.Type.MOUSE:
                    return new MousePaddle(game
                        , paddleTexture
                        , paddleActiveTexture
                        , new Vector3(halfWidth - halfPaddleWidth
                            , halfHeight - halfPaddleWidth
                            , 0f
                        )
                        , Vector3.Backward
                        , Vector3.Up
                        , paddleWidth
                        , paddleWidth
                        , paddleWidth
                        , sensitivity
                        , paddleSound
                        , width
                        , height
                    );

                case Paddle.Type.GAMEPAD:
                    return new GamepadPaddle(game
                        , paddleTexture
                        , paddleActiveTexture
                        , new Vector3(halfWidth - halfPaddleWidth
                            , halfHeight - halfPaddleWidth
                            , 0f
                        )
                        , Vector3.Backward
                        , Vector3.Up
                        , paddleWidth
                        , paddleWidth
                        , paddleWidth
                        , sensitivity * 5
                        , paddleSound
                        , width
                        , height
                    );

                case Paddle.Type.WEBCAM:
                    return new WebcamPaddle(game
                        , paddleTexture
                        , paddleActiveTexture
                        , new Vector3(halfWidth - halfPaddleWidth
                            , halfHeight - halfPaddleWidth
                            , 0f
                        )
                        , Vector3.Backward
                        , Vector3.Up
                        , paddleWidth
                        , paddleWidth
                        , paddleWidth
                        , paddleSound
                        , sensitivity
                        , width
                        , height
                    );

                default:
                    throw new ArgumentException();
            }
        }
示例#2
0
 public void AddPaddle(Paddle paddle)
 {
     this.paddles.Add(paddle);
 }