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); }
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(); } } }
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; } } } }
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); }