コード例 #1
0
    public void TestForClear()
    {
        CopyBoard();
        collector.Clear();

        // Test all blocks
        for (int r = 0; r < Rows; r++)
        {
            for (int c = 0; c < Cols; c++)
            {
                TestBlock(c, r);

                // Destroy blocks if we matched 3 of a kind
                if (collector.Count >= 3)
                {
                    // Destroy all the blocks
                    while (collector.Count > 0)
                    {
                        ScoreBlock(collector[0]);
                        ClearBlock(collector[0]);
                        collector.RemoveAt(0);
                    }
                }

                // Finish testing this block
                currentlyTesting = null;
                if (collector.Count > 0)
                {
                    collector.Clear();
                }
            }
        }
    }
コード例 #2
0
    public Match3Block InstantiateBlock(int blockType, int row, int col)
    {
        block = ObjectPools.Spawn <Match3Block>(
            BlockObjectPoolName,
            GetWorldPosition(col, row),
            _t);

        block.SetBlockInfo(this, blockType, col, row, BlockSprites[blockType - 1]);
        Blocks[row, col] = block;
        return(block);
    }
コード例 #3
0
    public void TestBlock(int x, int y)
    {
        // Already tested
        if (boardCopy[y, x] == null)
        {
            return;
        }

        // Start testing
        else if (currentlyTesting == null)
        {
            currentlyTesting = boardCopy[y, x];
            boardCopy[y, x]  = null;
            collector.Add(currentlyTesting);
        }

        // Not the same shape... leave and come back to this later
        else if (currentlyTesting.BlockType != boardCopy[y, x].BlockType)
        {
            return;
        }

        // Matching shape
        else
        {
            collector.Add(boardCopy[y, x]);
            boardCopy[y, x] = null;
        }

        // Test around the block
        if (x > 0)
        {
            TestBlock(x - 1, y);
        }
        if (y > 0)
        {
            TestBlock(x, y - 1);
        }
        if (x < Cols - 1)
        {
            TestBlock(x + 1, y);
        }
        if (y < Rows - 1)
        {
            TestBlock(x, y + 1);
        }
    }
コード例 #4
0
    public void TestForClear(int x, int y)
    {
        CopyBoard();
        collector.Clear();

        // Only the currently moved block can trigger a clear
        TestBlock(x, y);

        // Destroy blocks if we matched 3 of a kind
        if (collector.Count >= 3)
        {
            // Destroy all the blocks
            while (collector.Count > 0)
            {
                ScoreBlock(collector[0]);
                ClearBlock(y, x);
                collector.RemoveAt(0);
            }
        }

        // Finish testing this block
        currentlyTesting = null;
        collector.Clear();
    }
コード例 #5
0
 public void ClearBlock(Match3Block block)
 {
     ClearBlock(block.BlockY, block.BlockX);
 }
コード例 #6
0
 protected virtual void ScoreBlock(Match3Block block)
 {
 }