示例#1
0
        private void replaceTile(Map.Tile oldTile, Map.Tile newTile)
        {
            TileManager.SelectionType pasteSelection = new TileManager.SelectionType();

            for (int x = 0; x <= activeMap.Size.Width; x++)
            {
                for (int y = 0; y <= activeMap.Size.Width; y++)
                {
                    if ((activeMap[x, y] ?? Map.Tile.GetDefault()) == oldTile)
                    {
                        Paste(x, y, pasteSelection);
                    }
                }
            }
        }
示例#2
0
        private void replaceTile(Map.Tile oldTile, Map.Tile newTile)
        {
            TileManager.SelectionType pasteSelection = new TileManager.SelectionType();

            for (int x = 0; x <= activeMap.Size.Width; x++)
            {
                for (int y = 0; y <= activeMap.Size.Width; y++)
                {
                    if ((activeMap[x, y] ?? Map.Tile.GetDefault()) == oldTile)
                    {
                        Paste(x, y, pasteSelection);
                    }
                }
            }
        }
示例#3
0
        private void Paste(int tileX, int tileY, TileManager.SelectionType selectionType)
        {
            Dictionary <Point, int> selection;

            if (selectionType == TileManager.SelectionType.Object)
            {
                selection = TileManager.ObjectSelection;
            }
            else if (selectionType == TileManager.SelectionType.Pass)
            {
                selection = TileManager.PassSelection;
            }
            else if (selectionType == TileManager.SelectionType.Tile)
            {
                selection = TileManager.TileSelection;
            }
            else
            {
                return;
            }

            var graphics = Graphics.FromImage(pnlImage.Image);

            foreach (KeyValuePair <Point, int> keyValuePair in selection)
            {
                int mapTileX = keyValuePair.Key.X + tileX;
                int mapTileY = keyValuePair.Key.Y + tileY;

                if (mapTileX < activeMap.Size.Width && mapTileY < activeMap.Size.Height)
                {
                    activeMap[mapTileX, mapTileY] = activeMap[mapTileX, mapTileY] ?? Tile.DefaultTile;

                    // Go to next step of the loop if old value equals new value
                    int oldValue;
                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        oldValue = activeMap[mapTileX, mapTileY].ObjectNumber;
                    }
                    else if (selectionType == TileManager.SelectionType.Pass)
                    {
                        oldValue = activeMap[mapTileX, mapTileY].Passable ? 0 : 1;
                    }
                    else
                    {
                        oldValue = activeMap[mapTileX, mapTileY].TileNumber;
                    }

                    if (oldValue == keyValuePair.Value)
                    {
                        continue;
                    }

                    // Paste new value
                    Point point = new Point(mapTileX, mapTileY);
                    activeMap.IsModified = true;

                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        AddMapAction(new MapActionPasteObject(point, activeMap[mapTileX, mapTileY].ObjectNumber, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].ObjectNumber = keyValuePair.Value;
                    }

                    if (selectionType == TileManager.SelectionType.Pass)
                    {
                        AddMapAction(new MapActionPastePass(point, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].Passable = (keyValuePair.Value == 0 ? true : false);
                    }

                    if (selectionType == TileManager.SelectionType.Tile)
                    {
                        AddMapAction(new MapActionPasteTile(point, activeMap[mapTileX, mapTileY].TileNumber, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].TileNumber = keyValuePair.Value;
                    }

                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        for (int i = 0; i < 12; i++)
                        {
                            if (mapTileY - i >= 0)
                            {
                                var renderedTile = activeMap.GetFullyRenderedTile(mapTileX, mapTileY - i, sizeModifier,
                                                                                  activeMap[mapTileX, mapTileY].ObjectNumber == 0, showTiles, showObjects);
                                graphics.DrawImage(renderedTile, mapTileX * sizeModifier, (mapTileY - i) * sizeModifier);
                            }
                        }
                    }
                    else
                    {
                        var renderedTile = activeMap.GetFullyRenderedTile(mapTileX, mapTileY, sizeModifier,
                                                                          activeMap[mapTileX, mapTileY].TileNumber == 0, showTiles, showObjects);
                        graphics.DrawImage(renderedTile, mapTileX * sizeModifier, mapTileY * sizeModifier);
                    }
                }
            }
            graphics.Dispose();
            activeMap.IsModified = changeSinceRender = true;
            pnlImage.Image       = activeMap.GetRenderedMap(showTiles, showObjects);
            Invalidate();
        }
示例#4
0
        private void Paste(int tileX, int tileY, TileManager.SelectionType selectionType)
        {
            Dictionary <Point, int> selection;

            if (selectionType == TileManager.SelectionType.Object)
            {
                selection = TileManager.ObjectSelection;
            }
            else if (selectionType == TileManager.SelectionType.Pass)
            {
                selection = TileManager.PassSelection;
            }
            else if (selectionType == TileManager.SelectionType.Tile)
            {
                selection = TileManager.TileSelection;
            }
            else
            {
                return;
            }

            foreach (KeyValuePair <Point, int> keyValuePair in selection)
            {
                int mapTileX = keyValuePair.Key.X + tileX;
                int mapTileY = keyValuePair.Key.Y + tileY;

                if (mapTileX < activeMap.Size.Width && mapTileY < activeMap.Size.Height)
                {
                    activeMap[mapTileX, mapTileY] = activeMap[mapTileX, mapTileY] ?? Map.Tile.GetDefault();

                    // Go to next step of the loop if old value equals new value
                    int oldValue;
                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        oldValue = activeMap[mapTileX, mapTileY].ObjectNumber;
                    }
                    else if (selectionType == TileManager.SelectionType.Pass)
                    {
                        oldValue = activeMap[mapTileX, mapTileY].Passability ? 0 : 1;
                    }
                    else
                    {
                        oldValue = activeMap[mapTileX, mapTileY].TileNumber;
                    }

                    if (oldValue == keyValuePair.Value)
                    {
                        continue;
                    }

                    // Paste new value
                    Point point = new Point(mapTileX, mapTileY);
                    activeMap.IsModified = true;

                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        AddMapAction(new MapActionPasteObject(point, activeMap[mapTileX, mapTileY].ObjectNumber, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].ObjectNumber = keyValuePair.Value;
                    }

                    if (selectionType == TileManager.SelectionType.Pass)
                    {
                        AddMapAction(new MapActionPastePass(point, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].Passability = (keyValuePair.Value == 0 ? true : false);
                    }

                    if (selectionType == TileManager.SelectionType.Tile)
                    {
                        AddMapAction(new MapActionPasteTile(point, activeMap[mapTileX, mapTileY].TileNumber, keyValuePair.Value));
                        activeMap[mapTileX, mapTileY].TileNumber = keyValuePair.Value;
                    }

                    if (selectionType == TileManager.SelectionType.Object)
                    {
                        for (int i = 0; i < 12; i++)
                        {
                            if (mapTileY - i >= 0)
                            {
                                RenderSingleMapTile(mapTileX, mapTileY - i, activeMap[mapTileX, mapTileY].ObjectNumber == 0);
                            }
                        }
                        pnlImage.Invalidate();
                    }
                    else
                    {
                        RenderSingleMapTile(mapTileX, mapTileY, activeMap[mapTileX, mapTileY].TileNumber == 0);
                        pnlImage.Invalidate();
                    }
                }
            }
        }