Ejemplo n.º 1
0
 /// <summary>
 /// Sets all tiles.
 /// </summary>
 /// <param name="_type">The _type.</param>
 public void SetAllTiles(Tile.TileType _type)
 {
     for (int y = 0; y < floorHeight; y++)
     {
         for (int x = 0; x < floorWidth; x++)
         {
             selectedFloor.GetTile(x, y).Type = _type;
         }
     }
 }
Ejemplo n.º 2
0
            /// <summary>
            /// Handles the Up event of the picModify control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
            private void picModify_Up(object sender, EventArgs e)
            {
                isMouseDown = false;
                if (view.draggedPictureBox.Visible == true)
                {
                    PictureBox pictureBox = (PictureBox)sender;
                    System.Drawing.Point position = view.pnlDraw.PointToClient(Cursor.Position);
                    int pictureBoxX = (position.X - view.pnlDraw.AutoScrollPosition.X) / PICTURE_BOX_SIZE;
                    int pictureBoxY = (position.Y - view.pnlDraw.AutoScrollPosition.Y) / PICTURE_BOX_SIZE;
                    selectedTile = CurrentModel.selectedFloor.GetTile(pictureBoxX, pictureBoxY);

                    if (selectedTile != null && selectedTile.position != draggedTiles.position)
                    {
                        DialogResult dialogResult;
                        if (selectedTile.Type == Tile.TileType.Empty)
                        {
                            dialogResult = DialogResult.Yes;
                        }
                        else
                        {
                            dialogResult = MessageBox.Show("Voulez-vous vraiment écraser cette tuile?", "Drag", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                        }

                        if (dialogResult == DialogResult.Yes)
                        {
                            selectedTile.Type = draggedTiles.Type;
                            draggedTiles.Type = Tile.TileType.Empty;
                            draggedTiles = null;
                        }
                    }

                    view.draggedPictureBox.Visible = false;
                }
            }
Ejemplo n.º 3
0
            /// <summary>
            /// Handles the Down event of the picModify control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
            private void picModify_Down(object sender, MouseEventArgs e)
            {
                isMouseDown = true;
                picModify_Move(sender, e);
                if (e.Button == MouseButtons.Right)
                {
                    System.Drawing.Point position = view.pnlDraw.PointToClient(Cursor.Position);
                    int pictureBoxX = (position.X - view.pnlDraw.AutoScrollPosition.X) / PICTURE_BOX_SIZE;
                    int pictureBoxY = (position.Y - view.pnlDraw.AutoScrollPosition.Y) / PICTURE_BOX_SIZE;
                    selectedTile = CurrentModel.selectedFloor.GetTile(pictureBoxX, pictureBoxY);
                    if (draggedTiles == null)
                    {
                        draggedTiles = selectedTile;
                    }
                }

                PictureBox pictureBox = (PictureBox)sender;
                view.SelectPictureBox(pictureBox);

                if (view.tabControl.SelectedIndex == 0)
                {
                    view.lblTileName.Text = selectedTile.Type.ToString();
                    view.properties.SelectedObject = selectedTile;
                }
                else
                {
                    view.lblObjectName.Text = selectedTile.Type.ToString();
                    view.propertiesObject.SelectedObject = selectedTile.objectOnTile;
                }
            }
Ejemplo n.º 4
0
            /// <summary>
            /// Handles the Move event of the picModify control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
            public void picModify_Move(object sender, MouseEventArgs e)
            {
                if (isMouseDown)
                {
                    PictureBox pictureBox = (PictureBox)sender;
                    System.Drawing.Point position = view.pnlDraw.PointToClient(Cursor.Position);
                    int pictureBoxX = (position.X - view.pnlDraw.AutoScrollPosition.X) / PICTURE_BOX_SIZE;
                    int pictureBoxY = (position.Y - view.pnlDraw.AutoScrollPosition.Y) / PICTURE_BOX_SIZE;
                    if (pictureBoxX >= 0 && pictureBoxX < CurrentModel.selectedFloor.width &&
                        pictureBoxY >= 0 && pictureBoxY < CurrentModel.selectedFloor.height)
                    {
                        if (e.Button == MouseButtons.Left)
                        {
                            selectedTile = CurrentModel.selectedFloor.GetTile(pictureBoxX, pictureBoxY);
                            if (selectedTilePictureBox != null)
                            {
                                selectedTile.SetTile(selectedTilePictureBox.ImageLocation);
                            }
                            if (selectedObjectPictureBox != null)
                            {
                                selectedTile.objectOnTile.SetObject(selectedObjectPictureBox.ImageLocation);
                            }
                        }
                        else if (e.Button == MouseButtons.Right)
                        {
                            view.draggedPictureBox.Visible = true;
                            if (pictureBox.Parent != null && pictureBox.Parent is PictureBox)
                            {
                                view.draggedPictureBox.Image = (pictureBox.Parent as PictureBox).Image;
                            }
                            else
                            {
                                view.draggedPictureBox.Image = pictureBox.Image;
                            }
                            view.draggedPictureBox.Location = view.pnlDraw.PointToClient(Control.MousePosition);
                        }
                    }

                }
            }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes the specified _width.
 /// </summary>
 /// <param name="_width">The _width.</param>
 /// <param name="_height">The _height.</param>
 /// <param name="_type">The _type.</param>
 public void Initialize(int _width, int _height, Tile.TileType _type)
 {
     width = _width;
     height = _height;
     tiles = new Tile[_height][];
     for (int y = 0; y < _height; y++)
     {
         tiles[y] = new Tile[_width];
         for (int x = 0; x < _width; x++)
         {
             tiles[y][x] = new Tile();
             tiles[y][x].TileChanged += OnTerrainChanged;
             tiles[y][x].Initialize(_type, x, y);
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sets the tile.
 /// </summary>
 /// <param name="_X">The _ x.</param>
 /// <param name="_Y">The _ y.</param>
 /// <param name="_tile">The _tile.</param>
 public void SetTile(int _X, int _Y, Tile _tile)
 {
     tiles[_Y][_X] = _tile;
 }