Exemple #1
0
 public UrBoardWindowInterface(UrBoard _board, Vector2 _position, bool _leftPlayer = false, int _size = 64)
 {
     board         = _board;
     position      = _position;
     leftPlayer    = _leftPlayer;
     size          = _size;
     rolling       = false;
     playableMoves = null;
 }
Exemple #2
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     graphics.PreferredBackBufferWidth  = (UrBoard.board.GetLength(0) + 4) * 64; // set this value to the desired width of your window
     graphics.PreferredBackBufferHeight = UrBoard.board.GetLength(1) * 64;       // set this value to the desired height of your window
     graphics.ApplyChanges();
     Content.RootDirectory = "Content";
     board = new UrBoard();
     boardWindowController = new UrBoardWindowInterface(board, Vector2.UnitX * 64 * 2);
 }
Exemple #3
0
 public void play(Point mousePosition)
 {
     if (!rolling && playableMoves == null)
     {
         rolling = true;
     }
     else if (rolling)
     {
         rolling    = false;
         rollResult = board.roll();
         totalRoll  = 0;
         for (int i = 0; i < rollResult.Length; i++)
         {
             totalRoll += (rollResult[i] ? 1 : 0);
         }
         playableMoves = board.getPossibleMoves(totalRoll, leftPlayer);
     }
     else
     {
         bool changePlayer = false, nextTurn = false;
         if (playableMoves.Count == 0)
         {
             changePlayer = true;
             nextTurn     = true;
         }
         else
         {
             if (hover(mousePosition).X != -1)
             {
                 int currPos = board.getPionByBoardPos(hover(mousePosition), leftPlayer);
                 if (currPos > -1)
                 {
                     changePlayer = board.move(currPos, totalRoll, leftPlayer);
                     nextTurn     = true;
                 }
                 else
                 {
                     int nextPos = UrBoard.roadFromTilePos(hover(mousePosition), leftPlayer) - totalRoll;
                     if (nextPos > -1 && nextPos <= (leftPlayer ? UrBoard.leftRoad : UrBoard.rightRoad).Length)
                     {
                         currPos = board.getPionByBoardPos((leftPlayer ? UrBoard.leftRoad : UrBoard.rightRoad)[nextPos], leftPlayer);
                         if (playableMoves.Contains(currPos))
                         {
                             changePlayer = board.move(currPos, totalRoll, leftPlayer);
                             nextTurn     = true;
                         }
                     }
                     else if (nextPos == -1)
                     {
                         if ((leftPlayer ? board.leftPions : board.rightPions)[playableMoves[playableMoves.Count - 1]] == 0)
                         {
                             changePlayer = board.move(playableMoves[playableMoves.Count - 1], totalRoll, leftPlayer);
                             nextTurn     = true;
                         }
                     }
                 }
             }
         }
         if (nextTurn)
         {
             playableMoves = null;
             rolling       = true;
             if (changePlayer)
             {
                 leftPlayer = !leftPlayer;
             }
         }
     }
 }