protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button == MouseButtons.Middle)
            {
                _cameraDrag = true;
            }

            if (e.Button == MouseButtons.Left)
            {
                // find if we clicked on a tile and drag it
                var clickedTile = GetClickedTile();
                if (clickedTile != null)
                {
                    _draggedTile = clickedTile;
                }
                else
                {
                    if (CurrentLayer == EVENTS)
                    {
                        AddEvent();
                    }
                    else
                    {
                        AddTile();
                    }
                }
            }

            if (e.Button == MouseButtons.Right)
            {
                RemoveTile();
            }
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (e.Button == MouseButtons.Middle)
            {
                _cameraDrag = false;
            }
            else if (e.Button == MouseButtons.Left)
            {
                _draggedTile = null;
            }
        }
        private GameEditorTileData GetClickedTile()
        {
            GameEditorTileData tile = null;

            if (CurrentLayer == BUILDINGS)
            {
                tile = GetAtlasTileFromCoords(BUILDINGS, GetBuildings());
            }
            else if (CurrentLayer == OBJECTS)
            {
                tile = GetObjectTileFromCoords();
            }

            return(tile);
        }
        protected override void Initialize()
        {
            base.Initialize();

            _backgroundRectangle = new Texture2D(GraphicsDevice, 1, 1);
            _backgroundRectangle.SetData(new[] { Color.CadetBlue });
            _eventRectangle = new Texture2D(GraphicsDevice, 1, 1);
            _eventRectangle.SetData(new[] { Color.IndianRed });

            var viewportAdapter = new DefaultViewportAdapter(Editor.graphics);

            _camera = new OrthographicCamera(viewportAdapter);
            ResetCameraPosition();

            CurrentLayer     = GROUND;
            CurrentLevel     = 1;
            _groundTexture   = Editor.Content.Load <Texture2D>("Atlas/ground");
            _buildingTexture = Editor.Content.Load <Texture2D>("Atlas/buildings");

            // load atlas
            Atlas = new Dictionary <string, TextureAtlas>();
            var groundTiles   = GetGroundTiles();
            var buildingTiles = GetBuildingTiles();
            var objectTiles   = GetGameObjects();

            var groundAtlas   = new TextureAtlas(GROUND, _groundTexture, groundTiles);
            var buildingAtlas = new TextureAtlas(BUILDINGS, _buildingTexture, buildingTiles);

            Atlas.Add(GROUND, groundAtlas);
            Atlas.Add(BUILDINGS, buildingAtlas);

            GameObjects = GetGameObjects();
            LevelEvents = new List <GameEditorEvent>();

            // start with empty levels
            for (var i = 0; i < 5; i++)
            {
                var newLevel = new Level();
                _levels.Add(newLevel);
            }

            _draggedTile = null;

            OnInitialized(this, EventArgs.Empty);
        }