Пример #1
0
 private void WorldDisplay_MouseUp(object sender, MouseEventArgs e)
 {
     _selectedPoint = null;
 }
Пример #2
0
        private void WorldDisplay_MouseDown(object sender, MouseEventArgs e)
        {
            if (_cachedRegionImage == null)
                return;

            //Find out where the mouse is in regards to the overlay and return the info.
            int cellSize = _cachedRegionImage.Width / WorldView.RegionMapDimensions;
            int xOffset = (Width - _cachedRegionImage.Width) / 2;
            int yOffset = (Height - _cachedRegionImage.Height) / 2;

            if (e.X < xOffset)
                return;

            if (e.Y < yOffset)
                return;

            int x = (e.X - xOffset) / cellSize;
            int y = (e.Y - yOffset) / cellSize;

            if (x >= WorldView.RegionMapDimensions)
                return;

            if (y >= WorldView.RegionMapDimensions)
                return;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                _world.SelectTile(x, y);
                _selectedPoint = new PointInfo { X = x, Y = y, OriginalMouseX = e.X, OriginalMouseY = e.Y };
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                _world.SelectTile(x, y).MaterialType = PaintMaterial;
                if (PaintMaterial == WorldView.Material.Ocean)
                    _world.TileImage = 0;
                else
                    _world.TileImage = 36;
                //Repaint the landscape as we have changed what it looks like.
                _cachedRegionImage = null; WorldDisplay_SizeChanged(null, null); Refresh();
            }
        }