private void ActivateTile(MouseButtons mouseButton, Room room, Point2I tileLocation) { TileDataInstance tile = room.GetTile(tileLocation, EditorControl.CurrentLayer); if (mouseButton == MouseButtons.Left) { TileData selectedTilesetTileData = editorControl.SelectedTilesetTileData as TileData; if (selectedTilesetTileData != null) { // Remove the existing tile. if (tile != null) { room.RemoveTile(tile); editorControl.OnDeleteObject(tile); } // Place the new tile. room.PlaceTile( new TileDataInstance(selectedTilesetTileData), tileLocation.X, tileLocation.Y, editorControl.CurrentLayer); } } else if (mouseButton == MouseButtons.Right) { // Erase the tile. if (tile != null) { room.RemoveTile(tile); editorControl.OnDeleteObject(tile); } } else if (mouseButton == MouseButtons.Middle) { // Sample the tile. if (tile != null) { editorControl.SelectedTilesetTile = -Point2I.One; editorControl.SelectedTilesetTileData = tile.TileData; } } }
//----------------------------------------------------------------------------- // Internal methods //----------------------------------------------------------------------------- private void ActivateTile(MouseButtons mouseButton, Room room, Point2I tileLocation) { if (mouseButton == MouseButtons.Left) { room.CreateTile( editorControl.SelectedTilesetTileData, tileLocation.X, tileLocation.Y, editorControl.CurrentLayer ); } else if (mouseButton == MouseButtons.Right) { if (editorControl.CurrentLayer == 0) { room.CreateTile( editorControl.Tileset.DefaultTileData, tileLocation.X, tileLocation.Y, editorControl.CurrentLayer ); } else { room.RemoveTile(tileLocation.X, tileLocation.Y, editorControl.CurrentLayer); } } else if (mouseButton == MouseButtons.Middle) { // Sample the tile. TileDataInstance tile = room.GetTile(tileLocation, EditorControl.CurrentLayer); if (tile != null) { editorControl.SelectedTilesetTile = -Point2I.One; editorControl.SelectedTilesetTileData = tile.TileData; } } }