// civId
        // = 0...7 for 8 civs (including barbarians with civId=7)
        // = 8 for revealed map
        //public static Bitmap DrawMap(int civ, bool flatEarth)   // Draw for normal zoom level
        //{
        //    // Define a bitmap for drawing
        //    var mapPic = new Bitmap(32 * (2 * Map.Xdim + 1), 16 * (2 * Map.Ydim + 1));

        //    // Draw map
        //    int zoom = 0;   // Default zoom
        //    using (Graphics g = Graphics.FromImage(mapPic))
        //    {
        //        // Define starting and ending coords for drawing
        //        int colStart, colEnd;
        //        if (flatEarth)
        //        {
        //            colStart = 0;
        //            colEnd = Map.Xdim;
        //        }
        //        else    // Round world --> go few tiles beyond E and W borders in order to fill up blank space at map edge
        //        {
        //            colStart = -2;
        //            colEnd = Map.Xdim + 2;
        //        }

        //        // Draw
        //        for (int _row = 0; _row < Map.Ydim; _row++)
        //        {
        //            for (int _col = colStart; _col < colEnd; _col++)
        //            {
        //                // Determine column index in civ2-style coords
        //                int col = 2 * _col + (_row % 2);
        //                int row = _row;

        //                // Draw only if the tile is visible for each civ (index=8...whole map visible)
        //                if ((civ < 8 && Map.IsTileVisibleC2(col, row, civ)) || civ == 8)
        //                {
        //                    // Tiles
        //                    g.DrawImage(Map.TileC2(col, row).Graphic, 32 * col, 16 * row);

        //                    // Implement dithering in all 4 directions where non-visible tiles are
        //                    if (civ != 8)
        //                    {
        //                        int[] offset = new int[] { -1, 1 };
        //                        for (int tileX = 0; tileX < 2; tileX++)
        //                        {
        //                            for (int tileY = 0; tileY < 2; tileY++)
        //                            {
        //                                int colNew = col + offset[tileX];
        //                                int rowNew = row + offset[tileY];
        //                                if (colNew >= 0 && colNew < 2 * Map.Xdim && rowNew >= 0 && rowNew < Map.Ydim)   // Don't observe outside map limits
        //                                {
        //                                    if (!Map.IsTileVisibleC2(colNew, rowNew, civ))   // Surrounding tile is not visible -> dither
        //                                        g.DrawImage(Images.DitherDots[tileX, tileY], 32 * (col + tileX), 16 * (row + tileY));
        //                                }
        //                            }
        //                        }
        //                    }

        //                    // Units
        //                    List<IUnit> unitsHere = Game.GetUnits.Where(u => u.X == col && u.Y == row).ToList();
        //                    if (unitsHere.Count > 0)
        //                    {
        //                        IUnit unit = unitsHere.Last();
        //                        if (!unit.IsInCity)
        //                        {
        //                            Draw.Unit(g, unit, unitsHere.Count > 1, zoom, new Point(32 * col, 16 * row - 16));
        //                        }
        //                    }

        //                    // Cities
        //                    City city = Game.GetCities.Find(c => c.X == col && c.Y == row);
        //                    if (city != null)
        //                    {
        //                        Draw.City(g, city, true, zoom, new Point(32 * col, 16 * row - 16));
        //                    }
        //                }
        //            }
        //        }

        //        // City name text is drawn last
        //        foreach (City city in Game.GetCities)
        //        {
        //            //int[] ColRow = Ext.Civ2xy(new int[] { city.X, city.Y });  // Real coords from civ2 coords
        //            if ((civ < 8 && Map.IsTileVisibleC2(city.X, city.Y, civ)) || civ == 8)
        //            {
        //                //Bitmap cityNameBitmap = Draw.CityName(city, zoom);
        //                //g.DrawImage(cityNameBitmap, 32 * city.X + 32 - (cityNameBitmap.Width / 2), 16 * city.Y + 3 * 8);
        //            }
        //        }
        //    }

        //    return mapPic;
        //}

        public static Bitmap MapPart(int civ, int startX, int startY, int width, int height, int zoom, bool flatEarth)
        {
            // Define a bitmap for drawing
            var mapPic = new Bitmap(Game.Xpx * (2 * width + 1), Game.Ypx * (height + 1));

            // Draw map
            var cityList = new List <City>(); // Make a list of cities on visible map + their locations so you can draw city names

            using (var g = Graphics.FromImage(mapPic))
            {
                // Draw
                for (int _row = 0; _row < height; _row++)
                {
                    for (int _col = 0; _col < width; _col++)
                    {
                        // Determine column index in civ2-style coords
                        int col = 2 * _col + (_row % 2);
                        int row = _row;

                        // Draw only if the tile is visible for each civ (index=8...whole map visible)
                        if ((civ < 8 && Map.IsTileVisibleC2(startX + col, startY + row, civ)) || civ == 8)
                        {
                            // Tiles
                            Draw.Tile(g, startX + col, startY + row, zoom, new Point(4 * (8 + zoom) * col, 2 * (8 + zoom) * row));

                            // Implement dithering in all 4 directions where non-visible tiles are
                            if (civ != 8)
                            {
                                int[] offset = new int[] { -1, 1 };
                                for (int tileX = 0; tileX < 2; tileX++)
                                {
                                    for (int tileY = 0; tileY < 2; tileY++)
                                    {
                                        int colNew = col + offset[tileX];
                                        int rowNew = row + offset[tileY];
                                        if (colNew >= 0 && colNew < 2 * Map.Xdim && rowNew >= 0 && rowNew < Map.Ydim) // Don't observe outside map limits
                                        {
                                            if (!Map.IsTileVisibleC2(colNew, rowNew, civ))                            // Surrounding tile is not visible -> dither
                                            {
                                                g.DrawImage(Images.DitherDots[tileX, tileY], 4 * (8 + zoom) * (col + tileX), 2 * (8 + zoom) * (row + tileY));
                                            }
                                        }
                                    }
                                }
                            }

                            // Units
                            List <IUnit> unitsHere = Game.GetUnits.Where(u => u.X == startX + col && u.Y == startY + row).ToList();
                            if (unitsHere.Count > 0)
                            {
                                IUnit unit = unitsHere.Last();
                                if (!unit.IsInCity)
                                {
                                    Draw.Unit(g, unit, unitsHere.Count > 1, zoom, new Point(4 * (8 + zoom) * col, 2 * (8 + zoom) * (row - 1)));
                                }
                            }

                            // Cities
                            City city = Game.GetCities.Find(c => c.X == startX + col && c.Y == startY + row);
                            if (city != null)
                            {
                                Draw.City(g, city, true, zoom, new Point(4 * (8 + zoom) * col, 2 * (8 + zoom) * (row - 1)));
                                // Add city drawn on map & its position to list for drawing city names
                                cityList.Add(city);
                            }
                        }
                    }
                }

                // Grid
                if (Game.Options.Grid)
                {
                    for (int _row = 0; _row < height; _row++)
                    {
                        for (int _col = 0; _col < width; _col++)
                        {
                            // Determine column index in civ2-style coords
                            int col = 2 * _col + (_row % 2);
                            int row = _row;

                            // Draw only if the tile is visible for each civ (index=8...whole map visible)
                            if ((civ < 8 && Map.IsTileVisibleC2(startX + col, startY + row, civ)) || civ == 8)
                            {
                                Draw.Grid(g, zoom, new Point(4 * (8 + zoom) * col, 2 * (8 + zoom) * row));
                                //g.DrawImage(ModifyImage.Resize(Images.GridLines, zoom), 4 * (8 + zoom) * col, 2 * (8 + zoom) * row);
                            }
                        }
                    }
                }

                // City name text is drawn last
                foreach (City city in cityList)
                {
                    int[] destSq = new int[] { city.X - startX, city.Y - startY };
                    Draw.CityName(g, city, zoom, destSq);
                }
            }

            return(mapPic);
        }
        // Get animation frames for waiting unit
        public static List <Bitmap> UnitWaiting(bool viewPieceMode)
        {
            var animationFrames = new List <Bitmap>();

            // Get coords of central tile & which squares are to be drawn
            int[] centralCoords          = Game.ActiveXY; // Either from active unit or moving pieces
            var   coordsOffsetsToBeDrawn = new List <int[]>
            {
                new int[] { 0, -2 },
                new int[] { -1, -1 },
                new int[] { 1, -1 },
                new int[] { 0, 0 },
                new int[] { -1, 1 },
                new int[] { 1, 1 },
                new int[] { 0, 2 }
            };

            // Get 2 frames (one with and other without the active unit/moving piece)
            int[] coordsOffsetsPx;
            int   x, y;

            for (int frame = 0; frame < 2; frame++)
            {
                var _bitmap = new Bitmap(2 * Game.Xpx, 3 * Game.Ypx);
                using (var g = Graphics.FromImage(_bitmap))
                {
                    // Fill bitmap with black (necessary for correct drawing if image is on upper map edge)
                    g.FillRectangle(Brushes.Black, new Rectangle(0, 0, 2 * Game.Xpx, 3 * Game.Ypx));


                    foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn)
                    {
                        // Change coords of central offset
                        x = centralCoords[0] + coordsOffsets[0];
                        y = centralCoords[1] + coordsOffsets[1];
                        coordsOffsetsPx = new int[] { coordsOffsets[0] * Game.Xpx, coordsOffsets[1] * Game.Ypx };

                        if (x < 0 || y < 0 || x >= 2 * Map.Xdim || y >= Map.Ydim)
                        {
                            break;                                                          // Make sure you're not drawing tiles outside map bounds
                        }
                        // Tiles
                        Draw.Tile(g, x, y, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1] + Game.Ypx));

                        // Units
                        List <IUnit> unitsHere = Game.GetUnits.Where(u => u.X == x && u.Y == y).ToList();
                        if (unitsHere.Count > 0)
                        {
                            IUnit unit;
                            // If this is not tile with active unit or viewing piece, draw last unit on stack
                            if (x != Game.ActiveXY[0] && y != Game.ActiveXY[1])
                            {
                                unit = unitsHere.Last();
                                if (!unit.IsInCity)
                                {
                                    Draw.Unit(g, unit, unit.IsInStack, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1]));
                                }
                            }
                            // This tile has active unit/viewing piece
                            else
                            {
                                // Viewing piece mode is enabled, so draw last unit on stack
                                if (viewPieceMode)
                                {
                                    unit = unitsHere.Last();
                                    if (!unit.IsInCity)
                                    {
                                        Draw.Unit(g, unit, unit.IsInStack, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1]));
                                    }
                                }
                            }
                        }

                        // City
                        City city = Game.GetCities.Find(c => c.X == x && c.Y == y);
                        if (city != null)
                        {
                            Draw.City(g, city, true, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1]));
                        }

                        // Draw active unit if it's not moving
                        if (unitsHere.Count > 0)
                        {
                            // This tile has active unit/viewing piece
                            if (x == Game.ActiveXY[0] && y == Game.ActiveXY[1])
                            {
                                if (!viewPieceMode)
                                {
                                    // For first frame draw unit, for second not
                                    if (frame == 0)
                                    {
                                        Draw.Unit(g, Game.ActiveUnit, Game.ActiveUnit.IsInStack, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1]));
                                    }
                                }
                            }
                        }
                    }

                    // Gridlines
                    if (Game.Options.Grid)
                    {
                        foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn)
                        {
                            coordsOffsetsPx = new int[] { coordsOffsets[0] * Game.Xpx, coordsOffsets[1] * Game.Ypx + Game.Ypx };
                            Draw.Grid(g, Game.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1]));
                        }
                    }

                    // City names
                    foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn)
                    {
                        // Change coords of central offset
                        x = centralCoords[0] + coordsOffsets[0];
                        y = centralCoords[1] + coordsOffsets[1];

                        if (x >= 0 && y >= 0 && x < 2 * Map.Xdim && y < Map.Ydim)
                        {
                            break;                                                         // Make sure you're not drawing tiles outside map bounds
                        }
                        City city = Game.GetCities.Find(c => c.X == x && c.Y == y);
                        if (city != null)
                        {
                            Draw.CityName(g, city, Game.Zoom, new int[] { x, y });
                            //Bitmap cityNameBitmap = Draw.CityName(city, Game.Zoom);
                            //g.DrawImage(cityNameBitmap,
                            //    Game.Xpx * (coordsOffsets[0] + 1) - cityNameBitmap.Width / 2,
                            //    Game.Ypx * coordsOffsets[1] + 5 * 2 / Game.Ypx + Game.Ypx);
                        }
                    }

                    ////Viewing piece (is drawn on top of everything)
                    //if (MapPanel.ViewingPiecesMode)
                    //{
                    //    if (frame == 0)
                    //    {
                    //        g.DrawImage(Draw.ViewPiece, 0, 16);
                    //    }
                    //}
                }
                animationFrames.Add(_bitmap);
            }

            return(animationFrames);
        }