예제 #1
0
파일: Ball.cs 프로젝트: oab7/Pong_oab7
 /// <summary>
 /// Initializes a new instance of the <see cref="Ball"/> class.
 /// </summary>
 /// <param name="pongWorld">The pong world.</param>
 /// <param name="initialPosition">The initial position.</param>
 /// <param name="intialVelocity">The intial velocity.</param>
 public Ball(PongWorld pongWorld, Vector2 initialPosition, Vector2 intialVelocity)
 {
     this.pongWorld = pongWorld;
     this.position = initialPosition;
     this.velocity = intialVelocity;
     this.drawOrigin = new Vector2(Radius);
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LeadPursuitPaddleController"/> class.
 /// </summary>
 /// <param name="pongWorld">The pong world.</param>
 /// <param name="paddle">The paddle.</param>
 public LeadPursuitPaddleController(PongWorld pongWorld, Paddle paddle)
 {
     this.paddle = paddle;
     this.pongWorld = pongWorld;
     this.previousExampleCount = 0;
     this.previousOpponentExampleCount = 0;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RandomPaddleController"/> class.
 /// </summary>
 public RandomPaddleController(PongWorld world, Paddle paddle)
 {
     this.pongWorld = world;
     this.paddle = paddle;
     this.paddleVelocity = 0;
     this.paddleAcceloration = 0;
     this.paddleJerk = 0;
     this.random = new Random();
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PongScreen"/> class.
 /// </summary>
 public PongScreen()
     : base()
 {
     int leftBuffer = 200;
     int topBuffer = 40;
     this.pongWorld = new PongWorld(
         new Rectangle(leftBuffer, topBuffer, 1920 - leftBuffer * 2, 1080 - topBuffer * 2),
         Settings.BallSpeed,
         Settings.UseRoundedPaddles,
         Settings.LeftPaddleAI,
         Settings.RightPaddleAI);
 }
예제 #5
0
        /// <summary>
        /// Creates a new IPaddleController based on the specified
        /// pongWorld and paddle. The AI will be a random non-learner.
        /// </summary>
        /// <param name="pongWorld">The pong world.</param>
        /// <param name="paddle">The paddle.</param>
        /// <returns>
        /// The IPaddleController corresponding to the paddle.
        /// </returns>
        public static IPaddleController Create(PongWorld pongWorld, Paddle paddle)
        {
            int random = new Random().Next(3);
            switch (random)
            {
                case 0:
                    return Create(pongWorld, AIType.PurePursuit, paddle);
                case 1:
                    return Create(pongWorld, AIType.Random, paddle);
                case 2:
                    return Create(pongWorld, AIType.LeadPursuit, paddle);
            }

            return null;
        }
예제 #6
0
        /// <summary>
        /// Creates a new IPaddleController based on the specified
        /// pongWorld, aiType, and paddle.
        /// </summary>
        /// <param name="pongWorld">The pong world.</param>
        /// <param name="aiType">Type of the ai.</param>
        /// <param name="paddle">The paddle.</param>
        /// <returns>
        /// The IPaddleController corresponding to the paddle.
        /// </returns>
        public static IPaddleController Create(PongWorld pongWorld, AIType aiType, Paddle paddle)
        {
            switch (aiType)
            {
                case AIType.Human:
                    return new HumanPaddleController(pongWorld, paddle);
                case AIType.PurePursuit:
                    return new PurePursuitPaddleController(pongWorld, paddle);
                case AIType.LeadPursuit:
                    return new LeadPursuitPaddleController(pongWorld, paddle);
                case AIType.Random:
                    return new RandomPaddleController(pongWorld, paddle);
            }

            return null;
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HumanPaddleController"/> class.
 /// </summary>
 public HumanPaddleController(PongWorld pongWorld, Paddle paddle)
 {
     this.pongWorld = pongWorld;
     this.paddle = paddle;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PurePursuitPaddleController"/> class.
 /// </summary>
 /// <param name="pongWorld">The pong world.</param>
 /// <param name="paddle">The paddle.</param>
 public PurePursuitPaddleController(PongWorld pongWorld, Paddle paddle)
 {
     this.paddle = paddle;
     this.pongWorld = pongWorld;
 }
예제 #9
0
파일: Paddle.cs 프로젝트: oab7/Pong_oab7
 /// <summary>
 /// Initializes a new instance of the <see cref="Paddle"/> class.
 /// </summary>
 /// <param name="pongWorld">The pong world.</param>
 /// <param name="initialPosition">The initial position.</param>
 /// <param name="isLeft">if set to <c>true</c> [is left].</param>
 public Paddle(IPaddleController controller, PongWorld pongWorld, Vector2 initialPosition, bool isLeft)
 {
     this.totalPositiveResponces = 0;
     this.totalResponces = 0;
     this.isLeftPaddle = isLeft;
     this.position = initialPosition;
     this.oldPosition = initialPosition;
     this.target = initialPosition.Y;
     this.pongWorld = pongWorld;
     this.drawOrigin = new Vector2(Width / 2f, Height / 2f);
     this.controller = controller;
     this.controller.paddle = this;
     this.PreviousStates = new List<PaddleState>();
 }