public UrbMapData GetMapData() { UrbMapData output = new UrbMapData(); output.X = Xsize; output.Y = Ysize; output.Tiles = new UrbTileData[output.X * output.Y]; for (int i = 0; i < output.X; i++) { for (int ii = 0; ii < output.Y; ii++) { output.Tiles[i * output.X + ii] = MapTiles[i][ii].GetTileData(); } } return(output); }
public bool LoadMapFromData(UrbMapData input) { if (input.X != Xsize || input.Y != Ysize) { Debug.LogError("UrbMapData size mismatch. Load Canceled"); return(false); } for (int i = 0; i < input.X; i++) { for (int ii = 0; ii < input.Y; ii++) { bool success = MapTiles[i][ii].LoadTileFromData(input.Tiles[i * input.X + ii]); if (!success) { return(false); } } } return(true); }