public static void Replay(LevelDescription level, Cell[,] map, Cell[] left, Cell[] up)
    {
        int[,] mapData = level.GetMap();
        if (mapData == null)
        {
            return;
        }
        for (int i = 0; i < map.GetLength(0); i++)
        {
            for (int j = 0; j < map.GetLength(1); j++)
            {
                map[i, j].Clear();


                int needStone = 0;
                int hasStone  = 0;
                int type      = 1;

                GetCellSaveData(mapData[i, j], out type, out hasStone, out needStone);
                for (int k = 0; k < hasStone; k++)
                {
                    SetStone(map[i, j]);
                }
            }
        }
        int[] reserveLeft = level.GetLeftReserve();
        if (reserveLeft == null)
        {
            return;
        }
        int[] reserveUp = level.GetUpReserve();
        if (reserveLeft == null)
        {
            return;
        }
        for (int i = 0; i < left.Length; i++)
        {
            left[i].Clear();

            int count = reserveLeft[i];
            for (int k = 0; k < count; k++)
            {
                SetStone(left[i]);
            }
        }
        for (int i = 0; i < up.Length; i++)
        {
            up[i].Clear();
            int count = reserveUp[i];
            for (int k = 0; k < count; k++)
            {
                SetStone(up[i]);
            }
        }
    }
    public static Cell[,] GenerateLevel(GameObject parent,
                                        LevelDescription level, SaveData saveData = null)
    {
        AllStones.Clear();
        Color[,] colorMap = level.GetColorMap();
        int[,] mapData    = level.GetMap();
        if (mapData == null)
        {
            return(null);
        }
        Cell[,]  map = new Cell[mapData.GetLength(0), mapData.GetLength(1)];

        for (int i = 0; i < mapData.GetLength(0); i++)
        {
            for (int j = 0; j < mapData.GetLength(1); j++)
            {
                int needStone = 0;
                int hasStone  = 0;
                int type      = 1;

                GetCellSaveData(mapData[i, j], out type, out hasStone, out needStone);

                if (saveData != null)
                {
                    hasStone = saveData.Map[i, j];
                }



                Cell prefab = GetCellPrefabByType(type);
                Cell cell   = InstantiateCell(parent, prefab, new Vector2Int(i, j), new Vector2((i + 1), j));
                map[i, j] = cell;

                for (int k = 0; k < hasStone; k++)
                {
                    InstantiateStone(cell, stonePrefab);
                }
                if (colorMap != null)
                {
                    cell.SetColor(colorMap[i, j]);
                }
            }
        }



        return(map);
    }