Esempio n. 1
0
 /// <summary>
 /// Creates a view of a marble
 /// </summary>
 /// <param name="boardView">View of board</param>
 /// <param name="fromView">Square of marble</param>
 /// <param name="team">Team of marble</param>
 /// <param name="position">Position of square</param>
 public MarbleView(BoardView boardView, SquareView fromView, sbyte team, Vector2 position)
 {
     this.boardView = boardView;
     this.position  = position;
     FromView       = fromView;
     Team           = team;
 }
Esempio n. 2
0
        /// <summary>
        /// Sets the current start square as clicked
        /// </summary>
        /// <param name="view">Start Square</param>
        public void SetStart(SquareView view)
        {
            if (view.Team == currentPlayer.Team)
            {
                if (currentPlayer.IsHuman && currentRoll != null && IsAllowedToMoveMarbles())
                {
                    if (currentDrag == null)
                    {
                        Vector2 pos = view.GetPosition();
                        view.HasMarble = false;

                        currentDrag = new MarbleView(this, view, currentPlayer.Team, pos);
                        currentDrag.StartDrag();
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Resizes the board
        /// </summary>
        private void Resize(Rectangle size)
        {
            this.View = size;
            const int startOffset = 20;

            int tileWidth  = (int)Math.Round(View.Width / 29.166666666666666666666666666667);
            int tileHeight = (int)Math.Round(View.Height / 29.166666666666666666666666666667);

            int multiplierX = (int)Math.Round(View.Width / 12.962962962962962962962962962963);
            int multiplierY = (int)Math.Round(View.Height / 12.962962962962962962962962962963);

            for (int i = 0; i < 13; i++)
            {
                if (squares[i] == null)
                {
                    squares[i] = new BoardSquareView[13];
                }
                for (int j = 0; j < 13; j++)
                {
                    if (layout[i][j] != null)
                    {
                        Square square = new Square(layout[i][j]);
                        squares[i][j] = new BoardSquareView(this, square, new Rectangle(View.X + startOffset + j * multiplierX, View.Y + startOffset + i * multiplierY, tileWidth, tileHeight));
                    }
                }
            }

            int offset      = startOffset / 2;
            int porportionX = (int)Math.Round(View.Width / 15.555555555555555555555555555556);
            int porportionY = (int)Math.Round(View.Height / 15.555555555555555555555555555556);

            for (sbyte t = 0; t < Board.TEAM_COUNT; t++)
            {
                if (starts[t] == null)
                {
                    starts[t] = new SquareView[Board.TEAM_SIZE];
                }
                for (int m = 0; m < Board.TEAM_SIZE; m++)
                {
                    Rectangle target      = new Rectangle();
                    int       orientation = t + (2 - teamPerspective);
                    if (orientation < 0)
                    {
                        orientation += 4;
                    }
                    else if (orientation >= 4)
                    {
                        orientation -= 4;
                    }

                    switch (orientation)
                    {
                    case 0:     //UPPER LEFT
                        target = new Rectangle(View.X + offset + m * porportionX, View.Y + 10 + m * porportionY, tileWidth, tileHeight);
                        break;

                    case 1:     //UPPER RIGHT
                        target = new Rectangle(View.X + View.Width - offset - (m * porportionX), View.Y + offset + m * porportionY, tileWidth, tileHeight);
                        break;

                    case 2:     //BOTTOM RIGHT
                        target = new Rectangle(View.X + View.Width - offset - (m * porportionX), View.Y + View.Height - offset - (m * porportionY), tileWidth, tileHeight);
                        break;

                    case 3:     //BOTTOM LEFT
                        target = new Rectangle(View.X + offset + m * porportionX, View.Y + View.Height - offset - (m * porportionY), tileWidth, tileHeight);
                        break;

                    default:
                        break;
                    }

                    if (starts[t][m] == null)
                    {
                        starts[t][m] = new SquareView(this, target, t);
                    }
                    else
                    {
                        starts[t][m].Rect = target;
                    }
                }
            }
        }