Пример #1
0
        private void CopyTilesToEditor()
        {
            Tile[,] sourceTiles = new Tile[2, 2];
            int graphicsAddress = GetGraphicsAddress();


            if (showOverlays)
            {
                switch (LayoutOrder.SelectedIndex)
                {
                case 0:
                {
                    int tileCol = (int)(Canvas.GetLeft(SelectionRectangle) / 16);
                    int tileRow = (int)(Canvas.GetTop(SelectionRectangle) / 16);

                    sourceTiles[0, 0] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol, tileRow);
                    sourceTiles[1, 0] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol + 1, tileRow);
                    sourceTiles[0, 1] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol, tileRow + 1);
                    sourceTiles[1, 1] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol + 1, tileRow + 1);
                }
                break;

                case 1:
                {
                    int tileCol = (int)(Canvas.GetLeft(SelectionRectangle) / 16);
                    int tileRow = (int)(Canvas.GetTop(SelectionRectangle) / 16);

                    sourceTiles[0, 0] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol, tileRow);
                    sourceTiles[1, 0] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol, tileRow + 1);
                    sourceTiles[0, 1] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol + 1, tileRow);
                    sourceTiles[1, 1] = _graphicsService.GetExtraTileAtAddress(graphicsAddress, tileCol + 1, tileRow + 1);
                }
                break;
                }
            }
            else
            {
                int tileCol = (int)(Canvas.GetLeft(SelectionRectangle) / 16);
                int tileRow = (int)(Canvas.GetTop(SelectionRectangle) / 16);

                sourceTiles[0, 0] = _graphicsRenderer.GetMappedTile(tileCol, tileRow);
                sourceTiles[1, 0] = _graphicsRenderer.GetMappedTile(tileCol + 1, tileRow);
                sourceTiles[0, 1] = _graphicsRenderer.GetMappedTile(tileCol, tileRow + 1);
                sourceTiles[1, 1] = _graphicsRenderer.GetMappedTile(tileCol + 1, tileRow + 1);
            }

            _blockRenderer.Update(sourceTiles);
        }