Example #1
0
    private int GetScriptClickers(int nAnchor, int nC, int nR, ScriptClicker[] nScriptClickers)
    {
        //Get play area positions from a reference c, r
        //nC, nR are of play area grid
        int nLit = 0;

        for (int i = 0; i < 4 && nLit < 4; i++)
        {
            ScriptBlock nScrBlk = mCurrentPiece.blocks[i].GetComponent <ScriptBlock>();            //ScriptBlock from piece block
            int         nScrBlkCol = nScrBlk.GetColumn(nAnchor), nScrBlkRow = nScrBlk.GetRow(nAnchor);

            if (nC + nScrBlkCol < 0 || nR + nScrBlkRow < 0)
            {
                continue;                                                    //nScriptBlock.column and .row are relative to anchor
            }
            if (nC + nScrBlkCol >= mGridSpaces || nR + nScrBlkRow >= mGridSpaces)
            {
                continue;
            }

            ScriptClicker nScriptClicker = mClickers[nC + nScrBlkCol, nR + nScrBlkRow].GetComponent <ScriptClicker>();       //ScriptClicker on play area grid
            if (nScriptClicker.occupant == null || mHasBomb)
            {
                nScriptClickers[nLit] = nScriptClicker;
                nLit++;
            }
        }
        return(nLit);
    }
Example #2
0
    private int GetMinRow(int nAnchor, int nStartRow, int nColumn)
    {
        //Gets first occupied row below nStartRow at nColumn
        int nMin = 0;

        for (int i = 0; i < 4; i++)
        {
            ScriptBlock nScrBlk = mCurrentPiece.blocks[i].GetComponent <ScriptBlock>();            //ScriptBlock from piece block
            int         nScrBlkCol = nScrBlk.GetColumn(nAnchor), nScrBlkRow = nScrBlk.GetRow(nAnchor);

            if (nColumn + nScrBlkCol < 0 || nStartRow + nScrBlkRow < 0)
            {
                continue;                                                                //nScriptBlock.column and .row are relative to anchor
            }
            if (nColumn + nScrBlkCol >= mGridSpaces || nStartRow + nScrBlkRow >= mGridSpaces)
            {
                continue;
            }

            for (int r = nStartRow + nScrBlkRow, c = nColumn + nScrBlkCol; r > -1; r--)
            {
                if (mClickers[c, r].GetComponent <ScriptClicker>().occupant != null)
                {
                    if (r > nMin)
                    {
                        nMin = r;
                    }
                    break;
                }
            }
        }
        return(nMin);
    }