コード例 #1
0
ファイル: GenUtil.cs プロジェクト: GreatRedPanda/Sliding-Game
    public static Cell[] GenerateReserveUp(GameObject parent,
                                           LevelDescription level, SaveData saveData = null)
    {
        int[] reserve = level.GetUpReserve();

        if (reserve == null)
        {
            return(null);
        }
        Cell[] upReserve = new Cell[level.W];
        for (int i = 0; i < level.W; i++)
        {
            int count = reserve[i];
            if (saveData != null)
            {
                count = saveData.MapContainerUp[i];
            }
            CellContainer cell = InstantiateCell(parent, containerPrefab, new Vector2Int(i, level.H), new Vector2((i + 1), level.H)) as CellContainer;
            upReserve[i] = cell;
            for (int k = 0; k < count; k++)
            {
                InstantiateStone(cell, stonePrefab);
            }
        }
        return(upReserve);
    }
コード例 #2
0
ファイル: GenUtil.cs プロジェクト: GreatRedPanda/Sliding-Game
    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]);
            }
        }
    }