コード例 #1
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        internal void DrawBoard(Board board, Graphics graphics, Rectangle bounds)
        {
            RectangleF rect = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height);

            DrawGrid(graphics, board, rect);
            DrawFences(board, graphics, rect);
            DrawPlayers(board, graphics, rect);
        }
コード例 #2
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        internal Square GetSquareForCoordinates(int screenX, int screenY, Board board, Rectangle canvasRectangle)
        {
            int pixPerSquareH = canvasRectangle.Width / board.Size;
            int pixPerSquareV = canvasRectangle.Height / board.Size;

            int x = screenX / pixPerSquareH;
            int y = screenY / pixPerSquareV;
            return board.Squares.FirstOrDefault(s => s.X == x && s.Y == y);
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: AntonSh/Qu0rid0r
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="other">Board to copy from</param>
 protected Board(Board other)
 {
     throw new NotImplementedException("NYI");
 }
コード例 #4
0
 public ShortestPathRunner(Player player, Board board)
     : base(player)
 {
     _board = board;
 }
コード例 #5
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        private void DrawFences(Board board, Graphics graphics, RectangleF canvasRectangle)
        {
            foreach (Fence fence in board.Fences)
            {
                Link link = fence.SplittedLinks.First();
                Square[] squares = fence.SplittedLinks.SelectMany(l => l.Squares).ToArray();
                int leftColumn = squares.Min(s => s.X);
                int topRow = squares.Min(s => s.Y);

                if (link.Squares.First().X != link.Squares.Last().X)
                {
                    DrawVerticalFence(topRow, leftColumn, graphics, canvasRectangle, board.Size, _fencePen);
                }
                else
                {
                    DrawHorizontalFence(topRow, leftColumn, graphics, canvasRectangle, board.Size, _fencePen);
                }
            }
        }
コード例 #6
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        private void DrawPlayers(Board board, Graphics graphics, RectangleF canvasRectangle)
        {
            foreach (Player player in board.Players)
            {
                Brush brush = _playerColors[player.PlayerId];
                RectangleF squareRectangle = GetSquareRectangleF(canvasRectangle, board.Size, player.Position);

                graphics.FillEllipse(brush, squareRectangle);
            }
        }
コード例 #7
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        private void DrawGrid(Graphics graphics, Board board, RectangleF canvasRectangle)
        {
            foreach (var square in board.Squares)
            {
                Rectangle rect = GetSquareRectangle(canvasRectangle, board.Size, square);

                graphics.DrawRectangle(_gridPen, rect);
            }
        }