コード例 #1
0
        /// <summary>
        /// The base function called every time a tablet button
        /// is clicked by the user
        /// </summary>
        private void TabletClick(object sender, EventArgs e)
        {
            string radioTag;

            if (rad1.Checked == true)
            {
                radioTag = "dm";            //damaging
            }
            else if (rad2.Checked == true)
            {
                radioTag = "nt";            //non-damaging
            }
            else if (rad3.Checked == true)
            {
                radioTag = "nc";            //non-collision
            }
            else if (rad4.Checked == true)
            {
                radioTag = "mv";            //moving
            }
            else
            {
                radioTag = "nt";            //neutral/normal
            }
            ImageBox tempCopy = (ImageBox)sender;

            // Clear the button if the delete is checked
            if (chkDelete.Checked == true)
            {
                tempCopy.Image    = null;
                tempCopy.TileName = null;
                tempCopy.Tag      = null;
            }
            else
            {
                tempCopy.Image    = ImageSelect(currentTile);
                tempCopy.TileName = ToShortTiles[currentTile];
                tempCopy.Tag      = tempCopy.TileName + radioTag;
            }


            sender = tempCopy;
        }
コード例 #2
0
        private void TileClicked(object sender, EventArgs e)
        {
            ImageBox temp = (ImageBox)sender;

            currentTile = temp.TileName;
        }
コード例 #3
0
        private void InitializeTileBox()
        {
            //fields for tile setup
            int tileWidth  = (boxTiles.Width - 24) / 3;
            int tileHeight = tileWidth;
            int tileBuffer = 2;
            int topBuffer  = 15;

            string[,] LTiles = new string[, ]
            {
                { "LTopLeft", "LTopMid", "LTopRight" },
                { "LMidLeft", "dSolid", "LMidRight" },
                { "LBotLeft", "LBotMid", "LBotRight" }
            };

            string[,] dTiles = new string[, ]
            {
                { "dTopLeft", "dTopMid", "dTopRight" },
                { "dMidLeft", "dSolid", "dMidRight" },
                { "dBotLeft", "dBotMid", "dBotRight" }
            };

            string[,] nTiles = new string[, ]
            {
                { "nLeftTop", "nRightTop" },
                { "nLeftBot", "nRightBot" }
            };

            string[,] entities = new string[, ]
            {
                { "player", "e1" },
                { "egg", "flag" }
            };

            #region Adding 3x3 Tile Sets
            //loop that populates boxTiles container with first set of clickable tiles
            for (int column = 0; column < 3; column++)
            {
                for (int row = 0; row < 3; row++)
                {
                    ImageBox tempTile = new ImageBox();
                    tempTile.Height = tileHeight;
                    tempTile.Width  = tileWidth;
                    tempTile.Top    = (row * tileHeight) + (row * tileBuffer) + topBuffer;
                    tempTile.Left   = (column * tileWidth) + (column * tileBuffer) + 4;

                    tempTile.Visible  = true;
                    tempTile.Image    = ImageSelect(LTiles[row, column]);
                    tempTile.TileName = LTiles[row, column];


                    tempTile.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                    tempTile.SizeMode          = PictureBoxSizeMode.Zoom;
                    tempTile.Click            += TileClicked;

                    boxTiles.Controls.Add(tempTile);
                }
            }

            //loop that populates boxTiles container with second set of clickable tiles
            for (int column = 0; column < 3; column++)
            {
                for (int row = 0; row < 3; row++)
                {
                    ImageBox tempTile = new ImageBox();
                    tempTile.Height = tileHeight;
                    tempTile.Width  = tileWidth;
                    tempTile.Top    = (row * tileHeight) + (row * tileBuffer) + (topBuffer * 2) + (3 * tileHeight);
                    tempTile.Left   = (column * tileWidth) + (column * tileBuffer) + 4;

                    tempTile.Visible  = true;
                    tempTile.Image    = ImageSelect(dTiles[row, column]);
                    tempTile.TileName = dTiles[row, column];


                    tempTile.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                    tempTile.SizeMode          = PictureBoxSizeMode.Zoom;
                    tempTile.Click            += TileClicked;

                    boxTiles.Controls.Add(tempTile);
                }
            }
            #endregion



            #region Adding 2x2 Tile Sets
            //populates with entity stuff
            for (int column = 0; column < 2; column++)
            {
                for (int row = 0; row < 2; row++)
                {
                    ImageBox tempTile = new ImageBox();
                    tempTile.Height = tileHeight;
                    tempTile.Width  = tileWidth;
                    tempTile.Top    = (row * tileHeight) + (row * tileBuffer) + (topBuffer * 6) + (6 * tileHeight);
                    tempTile.Left   = (column * tileWidth) + (column * tileBuffer) + 4 + (boxTiles.Width / 6);

                    tempTile.Visible  = true;
                    tempTile.Image    = ImageSelect(entities[row, column]);
                    tempTile.TileName = entities[row, column];


                    tempTile.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                    tempTile.SizeMode          = PictureBoxSizeMode.Zoom;
                    tempTile.Click            += TileClicked;

                    boxTiles.Controls.Add(tempTile);
                }
            }

            //loop that populates boxTiles container with third set of clickable tiles
            for (int column = 0; column < 2; column++)
            {
                for (int row = 0; row < 2; row++)
                {
                    ImageBox tempTile = new ImageBox();
                    tempTile.Height = tileHeight;
                    tempTile.Width  = tileWidth;
                    tempTile.Top    = (row * tileHeight) + (row * tileBuffer) + (topBuffer * 20) + (6 * tileHeight);
                    tempTile.Left   = (column * tileWidth) + (column * tileBuffer) + 4 + (boxTiles.Width / 6);

                    tempTile.Visible  = true;
                    tempTile.Image    = ImageSelect(nTiles[row, column]);
                    tempTile.TileName = nTiles[row, column];


                    tempTile.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                    tempTile.SizeMode          = PictureBoxSizeMode.Zoom;
                    tempTile.Click            += TileClicked;

                    boxTiles.Controls.Add(tempTile);
                }
            }
            #endregion

            #region Indicator Box

            ImageBox indicator = new ImageBox();

            indicator.Height = tileHeight;
            indicator.Width  = tileWidth;
            indicator.Top    = (0 * tileHeight) + (0 * tileBuffer) + (topBuffer * 9) + (6 * tileHeight);
            indicator.Left   = (0 * tileWidth) + (0 * tileBuffer) + 4 + (boxTiles.Width / 6);

            indicator.Visible = true;
            indicator.Image   = ImageSelect("indicator");
            indicator.Name    = "indicator";

            indicator.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            indicator.SizeMode          = PictureBoxSizeMode.Zoom;
            indicator.Click            += TileClicked;

            boxTiles.Controls.Add(indicator);

            #endregion
        }
コード例 #4
0
        /// <summary>
        /// Creates the initially used empty tileMap
        /// </summary>
        private void InitialMap()
        {
            const int BASEX = 300;  // Top left corner of the container
            const int BASEY = 25;   // Top right corner of the container
            const int BASEW = 1200; // The width of the container
            const int BASEH = 770;  // The height of the container

            int btnX;               // X Position field
            int btnY;               // Y Position field
            int btnWidth;           // How wide the buttons are
            int btnHeight;          // How tall the buttons are

            int btnStacks;          // How many buttons tall (pulled from form)

            int.TryParse(tabletHeight.Text, out btnStacks);
            int btnRows;  // How many buttons wide (pulled from form)

            int.TryParse(tabletWidth.Text, out btnRows);

            if (btnRows == 0 || btnStacks == 0) //Check if the tablet's height and width will yeild a result
            {
                return;                         // Break the function if nothing it's not going to work
            }
            else // If there will be a result, change the tablet's setup
            {
                // First, clear all currently existing buttons in tabletButts
                foreach (var button in tabletButts)
                {
                    Controls.Remove(button);
                }
                for (int buttonNumber = tabletButts.Count - 1; buttonNumber >= 0; buttonNumber--)
                {
                    tabletButts.Remove(tabletButts[buttonNumber]);
                }

                // Next, recreate all of the buttons according to the new height and widths
                for (int h = 1; h <= btnStacks; h++)
                {
                    for (int w = 1; w <= btnRows; w++)
                    {
                        btnWidth  = BASEW / btnRows;
                        btnHeight = BASEH / btnStacks;
                        btnX      = BASEX + ((w - 1) * btnWidth);
                        btnY      = BASEY + ((h - 1) * btnHeight);

                        ImageBox temp = new ImageBox();
                        temp.Height            = btnHeight;
                        temp.Width             = btnWidth;
                        temp.Left              = btnX;
                        temp.Top               = btnY;
                        temp.Visible           = true;
                        temp.Image             = ImageSelect("blankTile");
                        temp.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                        temp.SizeMode          = PictureBoxSizeMode.Zoom;
                        temp.Click            += TabletClick;

                        tabletButts.Add(temp);
                        Controls.Add(temp);
                    }
                }
            }
        }