public static Selection SelectTiles(Map thisMap, Selection selection, int left, int top, int width, int height) { var result = new Selection(); result.AddRange(selection); for (int x = left; x < left + width; x++) for (int y = top; y < top + height; y++) { Tile t = thisMap.GetTileAcrossWrap(x, y); if (t != null && !selection.ContainsTile(t)) result.Add(t.GetCoordinate()); } return result; }
public static Map Resize(Map thisMap, ResizeOperation parameters) { Map map = (Map)thisMap.Clone(); map.SetDimensions(parameters.Width, parameters.Height); for (int x = 0; x < parameters.Width; x++) { for (int y = 0; y < parameters.Height; y++) { Tile t = new Tile(); t.PlotType = parameters.PlotType; t.Terrain = parameters.TerrainType; map.SetTile(x, y, t); } } int minX = 0; // west alignment int minY = 0; // south alignment if (parameters.HorAlign == HorizontalNeighbour.None) // center alignment minX = (thisMap.Width - parameters.Width) / 2; else if (parameters.HorAlign == HorizontalNeighbour.East) minX = thisMap.Width - parameters.Width; if (parameters.VerAlign == VerticalNeighbour.None) // center alignment minY = (thisMap.Height - parameters.Height) / 2; else if (parameters.VerAlign == VerticalNeighbour.North) minY = thisMap.Height - parameters.Height; for (int x = minX; x < minX + parameters.Width; x++) { for (int y = minY; y < minY + parameters.Height; y++) { Tile t = (Tile)thisMap.GetTileAcrossWrap(x, y, false, false); if(t != null) map.SetTile(x - minX, y - minY, t); } } return map; }