public BlockData GetNextCombinableBlock(GamingLogic2048.EPushingDirection _direction) //獲得某個方位上的下一個可結合之格子,沒辦法的話就回傳null
    {
        BlockData nextCombinableBlock = null;
        BlockData nextBlock           = this.GetNeighbor(_direction);

        if (nextBlock != null)
        {
            if (nextBlock.Conbinable)
            {
                nextCombinableBlock = nextBlock;
            }
            else
            {
                switch (nextBlock.m_eBlockType)
                {
                case EBlockType.Obstruct:     //障礙格子什麼也不做,自然的讓函式回傳null
                    nextCombinableBlock = null;
                    break;

                case EBlockType.None:     //空洞格子會一路繼續找下去,直到找到底或著下個可判斷的格子為止
                    nextCombinableBlock = nextBlock.GetNextCombinableBlock(_direction);
                    break;
                }
            }
        }
        return(nextCombinableBlock);
    }
Beispiel #2
0
    private List <List <BlockData> > GetPushingList(EPushingDirection _ePushingDirection) //獲得正要進行 "壓縮" 的行線群,所以是list(行線)的list(群)
    {
        List <List <BlockData> > listPushing = new List <List <BlockData> >();
        List <int>        listPushingPoint   = this.GetPushingPoint(_ePushingDirection);
        EPushingDirection eCombineDir        = GetOppositeDirection(_ePushingDirection);

        foreach (int iStartPoint in listPushingPoint)
        {
            BlockData        blockPick   = m_listBoard[iStartPoint];
            List <BlockData> pushingLine = new List <BlockData>
            {
                blockPick
            };
            while (blockPick.GetNextCombinableBlock(eCombineDir) != null)
            {
                blockPick = blockPick.GetNextCombinableBlock(eCombineDir);
                pushingLine.Add(blockPick);
            }
            listPushing.Add(pushingLine);
        }
        return(listPushing);
    }