コード例 #1
0
        private bool tryUncoverPairFromMemory()
        {
            bool uncoveredPartnerFromMemory = false;

            for (int i = 0; i < MemoryBoard.GetLength(0) && !uncoveredPartnerFromMemory; i++)
            {
                for (int j = 0; j < MemoryBoard.GetLength(1) && !uncoveredPartnerFromMemory; j++)
                {
                    if (OriginalBoard[i, j].Covered)
                    {
                        uncoveredPartnerFromMemory = tryUncoverPartnerFromMemory(MemoryBoard[i, j]);

                        if (uncoveredPartnerFromMemory)
                        {
                            OriginalBoard[i, j].WaitingForPartner = true;
                            OriginalBoard[i, j].Covered           = false;
                            onMoveDone();
                            OriginalBoard[i, j].UpdateFoundPartner();
                        }
                    }
                }
            }

            return(uncoveredPartnerFromMemory);
        }
コード例 #2
0
 public void InitialMemory()
 {
     for (int i = 0; i < MemoryBoard.GetLength(0); i++)
     {
         for (int j = 0; j < MemoryBoard.GetLength(1); j++)
         {
             MemoryBoard[i, j] = new Cell();
         }
     }
 }
コード例 #3
0
 private void copyUncoveredCells()
 {
     for (int i = 0; i < MemoryBoard.GetLength(0); i++)
     {
         for (int j = 0; j < MemoryBoard.GetLength(1); j++)
         {
             if (!OriginalBoard[i, j].Covered)
             {
                 MemoryBoard[i, j].Content = OriginalBoard[i, j].Content;
             }
         }
     }
 }
コード例 #4
0
        private bool tryUncoverPartnerFromMemory(Cell i_Cell)
        {
            bool foundCellInMemory = false;

            for (int i = 0; i < MemoryBoard.GetLength(0) && !foundCellInMemory; i++)
            {
                for (int j = 0; j < MemoryBoard.GetLength(1) && !foundCellInMemory; j++)
                {
                    if (MemoryBoard[i, j].Content != " " && MemoryBoard[i, j].Content == i_Cell.Content &&
                        MemoryBoard[i, j] != i_Cell && OriginalBoard[i, j] != i_Cell && !OriginalBoard[i, j].FoundPartner)
                    {
                        foundCellInMemory = true;
                        OriginalBoard[i, j].WaitingForPartner = true;
                        OriginalBoard[i, j].Covered           = false;
                        onMoveDone();
                        OriginalBoard[i, j].UpdateFoundPartner();
                    }
                }
            }

            return(foundCellInMemory);
        }