using System.Collections;
using UnityEngine;

[System.Serializable]
public class MapData 
{
    [System.Serializable]
    public class MapRow 
    {
        public string[] tiles;
    }

    public MapRow[] rows;
    public string name;
    public Monument start;
    public Monument end;
    public Monument[] signs;
    public Road2[] roads;
    public Tile[,] tiles;
    
    public void SetTiles()
    {
        tiles = new Tile[rows[0].tiles.Length, rows.Length];
        for (int row = 0; row < rows.Length; row++)
            for (int j = 0; j < rows[row].tiles.Length; j++)
                tiles[j,row] = new Tile(rows[row].tiles[j]);
    }

    override public string ToString()
    {
        var str = "";
        for (int i = 0; i < tiles.GetLength(0); i++)
        {
            str += "\n";
            for (int j = 0; j < tiles.GetLength(1); j++)
                str += tiles[i, j] + ", ";
        }
            
        var str2 = "";
        for (int i = 0; i < rows.Length; i++)
        {
            str2 += "\n";
            foreach (var item in rows[i].tiles)
                str2 += item + ", ";
        }
            
        return string.Format("Name: {0}, Start: {1}, End:{2}, Signs: {3}\nRoads: {4} Tiles: {5}, Rows {6}\n", name, start, end, signs, roads, str, str2);
    } 
}