Exemple #1
0
        private bool GameOver(Label label)
        {
            if (remainingCells.Count == 0)
            {
                return(true);
            }
            var cell = GameTable.GetCellPosition(label);

            ResetLabel.Text = String.Format("{0}, {1}\n{2}", cell.Row % 2, cell.Column % 2, IsCorner(cell.Row, cell.Column));

            // Corner cell case.
            if (IsCorner(cell.Row, cell.Column))
            {
                return(CornerCase(cell));
            }
            // Edge non-corner cell case.
            else if (IsEdge(cell.Row, cell.Column))
            {
                return(EdgeCase(cell));
            }
            // Centre case.
            else
            {
                CenterCase();
            }

            return(false);
        }
Exemple #2
0
        private void PlayerMove(Label label, string text)
        {
            // Update all private fields on click.
            label.Text = text;
            remainingCells.Remove(label); usedCells.Add(label);
            var cell = GameTable.GetCellPosition(label);

            filledCells[cell.Row, cell.Column] = true;

            if (GameOver(label))
            {
                EndGame(text);
            }
        }