Esempio n. 1
0
        private void tileClick(object sender, EventArgs e)
        {
            Console.WriteLine("oldSelectedTile changed from {0} to {1}", oldSelectedTile.ToString(), selectedTile.ToString());
            oldSelectedTile = selectedTile;


            foreach (TileSelector t in tilesPanel.Controls)
            {
                if (t.Location == oldSelectedTile)
                {
                    t.Image.Dispose();
                    t.Load(tileDirectory + t.Tag);
                    Console.WriteLine("oldTile reloaded from {0}", tileDirectory + t.Tag);
                }
            }

            TileSelector tile = (TileSelector)sender;

            Console.WriteLine("selectedTile changed from {0} to {1}", selectedTile.ToString(), tile.Location.ToString());
            selectedTile = tile.Location;
            Bitmap temp = (Bitmap)tile.Image;

            for (int x = 0; x < temp.Width; x += 2)
            {
                for (int y = 0; y < temp.Height; y += 2)
                {
                    temp.SetPixel(x, y, System.Drawing.Color.Blue);
                }
            }

            tile.Image = temp;
            tile.Refresh();
        }
Esempio n. 2
0
        private void ImportTileFolder(string tileDirectory)
        {
            try
            {
                string[] tiles = Directory.GetFiles(tileDirectory);

                lbox_Tiles.Items.Clear();

                //Clear the directory before using
                foreach (string file in Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Content\\Tiles\\"))
                {
                    File.Delete(file);
                }

                foreach (string tile in tiles)
                {
                    if (tile.EndsWith(".png") || tile.EndsWith(".jpg"))
                    {
                        string s = tile.Split('\\')[tile.Split('\\').Length - 1];
                        File.Copy(tile, Directory.GetCurrentDirectory() + "\\Content\\Tiles\\" + s, true);


                        lbox_Tiles.Items.Add(s);
                    }
                }

                lbox_Tiles.Enabled = true;

                //clear our display box
                tilesPanel.Controls.Clear();

                //then display the tiles in our tile display box
                int x = 0;
                int y = 0;

                foreach (String s in lbox_Tiles.Items)
                {
                    TileSelector ts = new TileSelector(x, y, this);
                    ts.Load(tileDirectory + "\\" + s);
                    ts.Parent = tilesPanel;
                    ts.Tag    = s;
                    ts.Click += new EventHandler(tileClick);

                    //increment location counters
                    x += 32;
                    if (x >= 256)
                    {
                        x  = 0;
                        y += 32;
                    }
                }
            }
            catch (ArgumentException)
            {
            }

            //update the tiles used by gamedraw
            GameDraw.LoadTileTextures();
        }
Esempio n. 3
0
        private void importDefaultTiles()
        {
            //default directory is \Content\Tiles\
            tileDirectory = Directory.GetCurrentDirectory() + "\\Content\\Tiles\\";

            try
            {
                string[] tiles = Directory.GetFiles(tileDirectory);

                lbox_Tiles.Items.Clear();

                foreach (string tile in tiles)
                {
                    if (tile.EndsWith(".png") || tile.EndsWith(".jpg"))
                    {
                        string s = tile.Split('\\')[tile.Split('\\').Length - 1];
                        //File.Copy(tile, Directory.GetCurrentDirectory() + "\\Content\\Tiles\\" + s, true);


                        lbox_Tiles.Items.Add(s);
                    }
                }

                lbox_Tiles.Enabled = true;

                //clear our display box
                tilesPanel.Controls.Clear();

                //then display the tiles in our tile display box
                int x = 0;
                int y = 0;

                foreach (String s in lbox_Tiles.Items)
                {
                    TileSelector ts = new TileSelector(x, y, this);
                    ts.Load(tileDirectory + s);
                    ts.Parent = tilesPanel;
                    ts.Tag    = s;
                    ts.Click += new EventHandler(tileClick);

                    //increment location counters
                    x += 32;
                    if (x >= 256)
                    {
                        x  = 0;
                        y += 32;
                    }
                }
            }
            catch (ArgumentException)
            {
            }
        }
Esempio n. 4
0
        private void tileClick(object sender, EventArgs e)
        {
            TileSelector sel = (TileSelector)sender;

            if (Control.ModifierKeys == Keys.Shift)
            {
                selectedTiles.Add(new SelectedTile((string)sel.Tag, sel.Location.X / 25, sel.Location.Y / 25));
            }
            //if no key is selected make sure the clear out the old selected tiles
            else
            {
                //refresh previously selected tiles
                foreach (TileSelector t in tilesPanel.Controls)
                {
                    foreach (SelectedTile s in selectedTiles)
                    {
                        if (t.Location.X == s.PositionX * 25 && t.Location.Y == s.PositionY * 25)
                        {
                            t.Image.Dispose();
                            t.Load(tileDirectory + t.Tag);
                            Console.WriteLine("oldTile reloaded from {0}", tileDirectory + t.Tag);
                        }
                    }
                }
                //empty the selected list
                selectedTiles.Clear();
                //add the newly select tile to the list
                selectedTiles.Add(new SelectedTile((string)sel.Tag, sel.Location.X / 25, sel.Location.Y / 25));
            }

            Bitmap temp = (Bitmap)sel.Image;

            for (int x = 0; x < temp.Width; x += 2)
            {
                for (int y = 0; y < temp.Height; y += 2)
                {
                    temp.SetPixel(x, y, System.Drawing.Color.Blue);
                }
            }

            sel.Image = temp;
            sel.Refresh();
        }