Beispiel #1
0
    private void GenerateNewRow()
    {
        //+ width for creating the bottom hidden row
        GameBlock[] blocks = new GameBlock[defaultGameBlocks.Length];
        System.Array.Copy(defaultGameBlocks, blocks, blocks.Length);
        for (int i = 0; i < width; ++i)
        {
            if (blocks.Length <= 2)
            {
                System.Array.Resize(ref blocks, defaultGameBlocks.Length);
                System.Array.Copy(defaultGameBlocks, blocks, blocks.Length);
            }

            GameBlock toPlace = UtilityFunctionLibrary.SpliceRandom(ref blocks);
            playGrid[i] = Instantiate(toPlace, BlocksRoot);
            playGrid[i].Move(i);

            MarkBlockDirty(playGrid[i]);
        }
    }
Beispiel #2
0
    public void SwapIndex(int _fromIndex, int _toIndex)
    {
        GameBlock from = GetGameBlock(_fromIndex);
        GameBlock to   = GetGameBlock(_toIndex);

        if (!from && !to)
        {
            return;
        }

        if (playGrid[_fromIndex] != null)
        {
            playGrid[_fromIndex].Index = _toIndex;
        }

        if (playGrid[_toIndex] != null)
        {
            playGrid[_toIndex].Index = _fromIndex;
        }

        UtilityFunctionLibrary.Swap(ref playGrid, _fromIndex, _toIndex);
    }