예제 #1
0
        private void BuildTileBrush(GraphicsDevice device)
        {
            DisposeTextures();

            _effectiveZoom     = ZoomFactor;
            _effectiveSpacingX = Model.GridSpacingX;
            _effectiveSpacingY = Model.GridSpacingY;
            _effectiveColor    = Model.GridColor;

            int tilesAcross = CalcBrushDimension(Model.GridSpacingX, MaxBrushSize, ZoomFactor);
            int tilesDown   = CalcBrushDimension(Model.GridSpacingY, MaxBrushSize, ZoomFactor);

            _tileBrushWidth  = tilesAcross;
            _tileBrushHeight = tilesDown;

            int zTileWidth  = (int)(Model.GridSpacingX * ZoomFactor);
            int zTileHeight = (int)(Model.GridSpacingY * ZoomFactor);

            int x = (int)(tilesAcross * zTileWidth);
            int y = (int)(tilesDown * zTileHeight);

            Color[] colors = new Color[x * y];
            //Color[] right = new Color[1 * y];
            //Color[] bottom = new Color[x * 1];

            for (int h = 0; h < tilesDown; h++)
            {
                for (int i = 0; i < x; i++)
                {
                    if (i % 4 != 2)
                    {
                        colors[h * x * zTileHeight + i] = Model.GridColor.ToXnaColor();
                        //bottom[i] = Model.GridColor.ToXnaColor();
                    }
                }
            }

            for (int w = 0; w < tilesAcross; w++)
            {
                for (int i = 0; i < y; i++)
                {
                    if (i % 4 != 2)
                    {
                        colors[i * x + w * zTileWidth] = Model.GridColor.ToXnaColor();
                        //right[i] = _gridColor;
                    }
                }
            }

            _tileGridBrush = new Texture2D(device, x, y, false, SurfaceFormat.Color);
            _tileGridBrush.SetData(colors);

            //_tileGridBrushRight = new Texture2D(device, 1, y, false, SurfaceFormat.Color);
            //_tileGridBrushRight.SetData(right);

            //_tileGridBrushBottom = new Texture2D(device, x, 1, false, SurfaceFormat.Color);
            //_tileGridBrushBottom.SetData(bottom);
        }
예제 #2
0
        private void BuildTileBrush(GraphicsDevice device)
        {
            DisposeTextures();

            _effectiveZoom = ZoomFactor;
            _effectiveSpacingX = Model.GridSpacingX;
            _effectiveSpacingY = Model.GridSpacingY;
            _effectiveColor = Model.GridColor;

            int tilesAcross = CalcBrushDimension(Model.GridSpacingX, MaxBrushSize, ZoomFactor);
            int tilesDown = CalcBrushDimension(Model.GridSpacingY, MaxBrushSize, ZoomFactor);

            _tileBrushWidth = tilesAcross;
            _tileBrushHeight = tilesDown;

            int zTileWidth = (int)(Model.GridSpacingX * ZoomFactor);
            int zTileHeight = (int)(Model.GridSpacingY * ZoomFactor);

            int x = (int)(tilesAcross * zTileWidth);
            int y = (int)(tilesDown * zTileHeight);

            Color[] colors = new Color[x * y];
            //Color[] right = new Color[1 * y];
            //Color[] bottom = new Color[x * 1];

            for (int h = 0; h < tilesDown; h++) {
                for (int i = 0; i < x; i++) {
                    if (i % 4 != 2) {
                        colors[h * x * zTileHeight + i] = Model.GridColor.ToXnaColor();
                        //bottom[i] = Model.GridColor.ToXnaColor();
                    }
                }
            }

            for (int w = 0; w < tilesAcross; w++) {
                for (int i = 0; i < y; i++) {
                    if (i % 4 != 2) {
                        colors[i * x + w * zTileWidth] = Model.GridColor.ToXnaColor();
                        //right[i] = _gridColor;
                    }
                }
            }

            _tileGridBrush = new Texture2D(device, x, y, false, SurfaceFormat.Color);
            _tileGridBrush.SetData(colors);

            //_tileGridBrushRight = new Texture2D(device, 1, y, false, SurfaceFormat.Color);
            //_tileGridBrushRight.SetData(right);

            //_tileGridBrushBottom = new Texture2D(device, x, 1, false, SurfaceFormat.Color);
            //_tileGridBrushBottom.SetData(bottom);
        }