示例#1
0
        // public
        /// <summary>
        /// Creates a guielement that displays how the board looks like and keeps updated when
        /// the board changes.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="board">The Board to visualize.</param>
        /// <param name="role">The Role to view the board from, for example 
        /// the overlord may see the entire board from the beginning</param>
        /// <returns>A Guielement that displays the board.</returns>
        public static GUIElement CreateBoardElement(Game game, Board board, Role role)
        {
            Contract.Requires(game != null);
            Contract.Requires(board != null);
            Contract.Ensures(Contract.Result<GUIElement>() != null);
            Contract.Ensures(Contract.Result<GUIElement>().Bound.X == 0);
            Contract.Ensures(Contract.Result<GUIElement>().Bound.Y == 0);
            Contract.Ensures(Contract.Result<GUIElement>().Bound.Width == (int)(game.GraphicsDevice.Viewport.Width * (3 / 4.0)));
            Contract.Ensures(Contract.Result<GUIElement>().Bound.Height == game.GraphicsDevice.Viewport.Height);

            return new BoardElement(game, board, role);
        }
示例#2
0
        /// <summary>
        /// Creates a new BoardGUIElement for the given parameters.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="board">The Board to visualize.</param>
        /// <param name="role">The Role determines how much of the Board is visible.</param>
        public BoardElement(Game game, Board board, Role role)
            : base(game, "board", 0, 0, (int)(game.GraphicsDevice.Viewport.Width * (3 / 4.0)), game.GraphicsDevice.Viewport.Height)
        {
            this.board = board;
            xDisp = -2 * TileSize;
            yDisp = 17 * TileSize;
            this.role = role;
            this.SetDrawBackground(false);

            // marked
            this.markedSquares = new Dictionary<Vector2, bool>();
            this.markTexture = new Texture2D(Game.GraphicsDevice, 1, 1);
            this.markTexture.SetData(new Color[] { Color.White });
        }