Exemplo n.º 1
0
 private void Map_GridBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (Tileset_GridBox.SelectionIsEmpty())
     {
         Map_GridBox.Hover = new bool[1, 1] {
             { false }
         };
     }
     else if (Tool_Tile_Button.Checked)
     {
         Rectangle selection = Tileset_GridBox.GetSelectionRectangle();
         Map_GridBox.Hover = new bool[selection.Width, selection.Height];
         for (int y = 0; y < selection.Height; y++)
         {
             for (int x = 0; x < selection.Width; x++)
             {
                 Map_GridBox.Hover[x, y] = Tileset_GridBox.Selection[selection.X + x, selection.Y + y];
             }
         }
     }
     else
     {
         Map_GridBox.Hover = new bool[1, 1] {
             { true }
         };
     }
 }
Exemplo n.º 2
0
        void Core_TileTool()
        {
            Rectangle selection = Tileset_GridBox.GetSelectionRectangle();

            if (Changes_CheckBox.Checked)
            {
                for (int y = 0; y < selection.Height; y++)
                {
                    for (int x = 0; x < selection.Width; x++)
                    {
                        if (Map_GridBox.Hovered.X + x < 0 || Map_GridBox.Hovered.X + x >= CurrentMap.WidthTiles ||
                            Map_GridBox.Hovered.Y + y < 0 || Map_GridBox.Hovered.Y + y >= CurrentMap.HeightTiles)
                        {
                            continue;
                        }

                        if (Map_GridBox.Hover[x, y])
                        {
                            CurrentMap.Changes.SetTile(
                                Changes_NumBox.Value,
                                Map_GridBox.Hovered.X + x,
                                Map_GridBox.Hovered.Y + y,
                                (selection.X + x) + (selection.Y + y) * 32);
                        }
                    }
                }

                Core.SuspendUpdate();
                Core_WriteMapChanges();
                Core.ResumeUpdate();
            }
            else if (Map_GridBox.Hover != null)
            {
                for (int y = 0; y < selection.Height; y++)
                {
                    for (int x = 0; x < selection.Width; x++)
                    {
                        if (Map_GridBox.Hovered.X + x < 0 || Map_GridBox.Hovered.X + x >= CurrentMap.WidthTiles ||
                            Map_GridBox.Hovered.Y + y < 0 || Map_GridBox.Hovered.Y + y >= CurrentMap.HeightTiles)
                        {
                            continue;
                        }

                        if (Map_GridBox.Hover[x, y])
                        {
                            CurrentMap.Layout[Map_GridBox.Hovered.X + x,
                                              Map_GridBox.Hovered.Y + y] =
                                (selection.X + x) + (selection.Y + y) * 32;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        void Core_FillTool()
        {
            Rectangle selection = Tileset_GridBox.GetSelectionRectangle();

            int[] tiles = new int[Tileset_GridBox.GetSelectionAmount()];
            int   index = 0;

            for (int y = 0; y < selection.Height; y++)
            {
                for (int x = 0; x < selection.Width; x++)
                {
                    if (Tileset_GridBox.Selection[selection.X + x, selection.Y + y])
                    {
                        tiles[index++] = (selection.X + x) + (selection.Y + y) * 32;
                    }
                }
            }
            if (tiles.Length == 0)
            {
                Program.ShowMessage("No tile is selected in the tileset.");
            }
            else
            {
                Point start = Map_GridBox.Hovered;
                bool[,] map = new bool[CurrentMap.WidthTiles, CurrentMap.HeightTiles];
                int tile = CurrentMap.Layout[start.X, start.Y];
                Core_FillHelper(ref map, ref tile, start.X, start.Y);

                Random random = new Random();
                for (int y = 0; y < CurrentMap.HeightTiles; y++)
                {
                    for (int x = 0; x < CurrentMap.WidthTiles; x++)
                    {
                        if (map[x, y])
                        {
                            CurrentMap.Layout[x, y] = tiles[random.Next(tiles.Length)];
                        }
                    }
                }
            }
        }