예제 #1
0
    public static Cell[] GenerateReserveLeft(GameObject parent,
                                             LevelDescription level, SaveData saveData = null)
    {
        int[] reserve = level.GetLeftReserve();
        if (reserve == null)
        {
            return(null);
        }
        Cell[] leftReserve = new Cell[level.H];

        for (int j = 0; j < level.H; j++)
        {
            int count = reserve[j];
            if (saveData != null)
            {
                count = saveData.MapContainerLeft[j];
            }
            CellContainer cell = InstantiateCell(parent, containerPrefab, new Vector2Int(-1, j), new Vector2((0), j)) as CellContainer;
            leftReserve[j] = cell;
            for (int k = 0; k < count; k++)
            {
                InstantiateStone(cell, stonePrefab);
            }
        }

        return(leftReserve);
    }
예제 #2
0
    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]);
            }
        }
    }