Exemple #1
0
 public Pool(Player player1, Player player2)
 {
     this.Balls = new List<Ball>();
     this.Sides = new List<Side>();
     this.Player1 = player1;
     this.Player2 = player2;
     this.PocketCentres = new Vector2[] { new Vector2(50, 40), new Vector2(335, 40), new Vector2(615, 40),
                                         new Vector2(50,315), new Vector2(335,315), new Vector2(615, 315) };
     InitializeTable();
 }
Exemple #2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     player1 = new Player(true);
     player2 = new Player(false);
     this.pool = new Pool(player1,player2);
     this.IsMouseVisible = true;
     this.mouseScrollState = 0;
     this.bot = new CollisionDetectingBot(pool, player2);
     base.Initialize();
 }
Exemple #3
0
 public PocketAimingBot(Pool pool, Player player)
     : base(pool,player)
 {
 }
Exemple #4
0
 private void HandleFirstBallCollision(int index, Player playerOnTurn)
 {
     if (playerOnTurn.BallTypeChosen == BallType.Solids && index > 7)
     {
         shouldSwitchPlayers = true;
         Fault = true;
     }
     if (playerOnTurn.BallTypeChosen == BallType.Stripes && index < 9)
     {
         shouldSwitchPlayers = true;
         Fault = true;
     }
 }
Exemple #5
0
        private void HandleBallPotted(Ball ball, Player playerOnTurn, Player otherPlayer)
        {
            if (ball.Number == 0) // the white ball has been potted
            {
                shouldSwitchPlayers = true;
                Fault = true;
                return;
            }

            if (ball.Number == 8) // the black ball has been potted
            {
                if (playerOnTurn.ShouldPotBlack(Balls))
                {
                    playerOnTurn.Won = true;
                    otherPlayer.Won = false;
                }
                else
                {
                    playerOnTurn.Won = false;
                    otherPlayer.Won = true;
                }
            }

            if (playerOnTurn.BallTypeChosen == BallType.None) // noone has potted a ball yet
            {
                if (ball.Number > 8)  // a striped ball has been potted
                {
                    playerOnTurn.BallTypeChosen = BallType.Stripes;
                    otherPlayer.BallTypeChosen = BallType.Solids;
                }
                else // a solid ball has been potted
                {
                    playerOnTurn.BallTypeChosen = BallType.Solids;
                    otherPlayer.BallTypeChosen = BallType.Stripes;
                }
            }
            else if (playerOnTurn.BallTypeChosen == BallType.Solids) // the player should pot solids
            {
                if (ball.Number > 8) // the player potted stripe ball
                {
                    shouldSwitchPlayers = true;
                    Fault = true;
                }
            }
            else // the player should pot stripes
            {
                if (ball.Number < 8) // the player potted solid
                {
                    shouldSwitchPlayers = true;
                    Fault = true;
                }
            }
        }
 public CollisionDetectingBot(Pool pool, Player player)
     : base(pool, player)
 {
 }
Exemple #7
0
 public Bot(Pool pool, Player player)
 {
     this.pool = pool;
     this.player = player; // the bot will play as 2nd player
 }