private void Init(int width, int height) { _width = width; _height = height; if (_size == null) { MapSize bestMapSize = new MapSize(); int bestValue = int.MaxValue; foreach (MapSize ms in Provider.Instance.MapSizes.Values) { int dist = (ms.Size.Width - Width) * (ms.Size.Width - Width) + (ms.Size.Height - Height) * (ms.Size.Height - Height); if (dist < bestValue) { bestValue = dist; bestMapSize = ms; } } _size = bestMapSize; } _tiles = new MapCell[_width * _height]; Fill("Ocean"); }
public MapData(MapSize size) { _size = size; Init(size.Size.Width, size.Size.Height); }