コード例 #1
0
 void GridCellTapped(Position gridPosition, Position cellPosition, int currentNumber)
 {
     if (m_solutionGrid != null)
     {
         if (currentNumber > 0)
         {
             if (OnGridSelectedNumber != null)
             {
                 OnGridSelectedNumber(currentNumber);
             }
         }
         else if (m_numberSelected > 0)
         {
             if (m_pencillingIn)
             {
                 TogglePencilledInNumber(gridPosition, m_numberSelected, cellPosition);
             }
             else if (m_erasing)
             {
                 ClearGridNumber(gridPosition, cellPosition);
             }
             else
             {
                 SetUserNumber(gridPosition, cellPosition, m_numberSelected);
             }
             if (OnCellTapped != null)
             {
                 OnCellTapped(gridPosition, cellPosition);
             }
         }
     }
 }
コード例 #2
0
 void GridCellCleared(int number, Position gridPosition, Position cellPosition)
 {
     if (m_suppliedNumberCount[number - 1] > 0)
     {
         m_suppliedNumberCount[number - 1]--;
     }
     if (OnCellCleared != null)
     {
         OnCellCleared(number, gridPosition, cellPosition);
     }
 }
コード例 #3
0
 void GridCellRightTapped(Position gridPosition, Position cellPosition, int currentNumber)
 {
     if (m_numberSelected > 0)
     {
         TogglePencilledInNumber(gridPosition, m_numberSelected, cellPosition);
     }
 }
コード例 #4
0
 public void SetUserNumber(Position gridPosition, Position cellPosition, int number)
 {
     if (number < 1 || number > m_gridSize)
     {
         throw new Exception("SetUserNumber() - Number out of range.");
     }
     else if (gridPosition.Row < 0 || gridPosition.Row > 2)
     {
         throw new Exception("SetUserNumber() - Row index out of range.");
     }
     else if (gridPosition.Column < 0 || gridPosition.Column > 2)
     {
         throw new Exception("SetUserNumber() - Column index out of range.");
     }
     else
     {
         if (m_suppliedNumberCount[number - 1] < m_numberCountLimit)
         {
             int row = gridPosition.Row * 3 + cellPosition.Row;
             int column = gridPosition.Column * 3 + cellPosition.Column;
             bool numberIsCorrect = m_solutionGrid[row, column] == number;
             if (m_theGrids[gridPosition.Row, gridPosition.Column].SetUserNumber(cellPosition, number, numberIsCorrect))
             {
                 m_suppliedNumberCount[number - 1]++;
             }
         }
     }
 }
コード例 #5
0
 public void TogglePencilledInNumber(Position gridPosition, int number, Position cellPosition)
 {
     if (number < 1 || number > m_gridSize)
     {
         throw new Exception("TogglePencilledInNumber() - Number out of range.");
     }
     else if (gridPosition.Row < 0 || gridPosition.Row > 2)
     {
         throw new Exception("TogglePencilledInNumber() - Row index out of range.");
     }
     else if (gridPosition.Column < 0 || gridPosition.Column > 2)
     {
         throw new Exception("TogglePencilledInNumber() - Column index out of range.");
     }
     else
     {
         m_theGrids[gridPosition.Row, gridPosition.Column].TogglePencilledInNumber(number, cellPosition);
     }
 }
 public void HighlightPencilMarks(Position cellPosition, bool highlight)
 {
     if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("highlightPencilMarks() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("highlightPencilMarks() - Column index out of range.");
     }
     else
     {
         m_gridSquares[cellPosition.Row, cellPosition.Column].HighlightPencils = highlight;
     }
 }
コード例 #7
0
 public void SetGivenNumber(Position gridPosition, Position cellPosition, int number)
 {
     if (number < 1 || number > m_gridSize)
     {
         throw new Exception("SetGivenNumber() - Number out of range.");
     }
     else if (gridPosition.Row < 0 || gridPosition.Row > 2)
     {
         throw new Exception("SetGivenNumber() - Row index out of range.");
     }
     else if (gridPosition.Column < 0 || gridPosition.Column > 2)
     {
         throw new Exception("SetGivenNumber() - Column index out of range.");
     }
     else
     {
         if (m_suppliedNumberCount[number - 1] < m_numberCountLimit)
         {
             if (m_theGrids[gridPosition.Row, gridPosition.Column].SetGivenNumber(cellPosition, number))
             {
                 m_suppliedNumberCount[number - 1]++;
             }
         }
     }
 }
 public int CellValue(Position cellPosition)
 {
     if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("CellValue() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("CellValue() - Column index out of range.");
     }
     else
     {
         return m_gridSquares[cellPosition.Row, cellPosition.Column].Number;
     }
 }
コード例 #9
0
 public void ClearGridNumber(Position gridPosition, Position cellPosition)
 {
     if (gridPosition.Row < 0 || gridPosition.Row > 2)
     {
         throw new Exception("ClearGridNumber() - Row index out of range.");
     }
     else if (gridPosition.Column < 0 || gridPosition.Column > 2)
     {
         throw new Exception("ClearGridNumber() - Column index out of range.");
     }
     else
     {
         int cellNumber = GridCellValue(gridPosition, cellPosition);
         if (cellNumber > 0)
         {
             if (m_suppliedNumberCount[cellNumber - 1] > 0)
             {
                 m_suppliedNumberCount[cellNumber - 1]--;
             }
             m_theGrids[gridPosition.Row, gridPosition.Column].ClearNumber(cellPosition);
             if (OnCellCleared != null)
             {
                 OnCellCleared(cellNumber, gridPosition, cellPosition);
             }
         }
     }
 }
 void GridCellCleared(int number, Position cellPosition)
 {
     if (OnCellCleared != null)
     {
         OnCellCleared(number, m_gridPosition, cellPosition);
     }
 }
 void GridCellTapped(Position cellPosition, int currentNumber)
 {
     if (OnCellTapped != null)
     {
         OnCellTapped(m_gridPosition, cellPosition, currentNumber);
     }
 }
 public void TogglePencilledInNumber(int number, Position cellPosition)
 {
     if (number < 1 || number > 9)
     {
         throw new Exception("TogglePencilledInNumber() - Number out of range.");
     }
     else if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("TogglePencilledInNumber() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("TogglePencilledInNumber() - Column index out of range.");
     }
     else
     {
         m_gridSquares[cellPosition.Row, cellPosition.Column].TogglePencilledInNumber(number);
     }
 }
 public void ShowErrors(Position cellPosition, bool showErrors)
 {
     if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("ShowErrors() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("ShowErrors() - Column index out of range.");
     }
     else
     {
         m_gridSquares[cellPosition.Row, cellPosition.Column].ShowErrors = showErrors;
     }
 }
 public bool SetUserNumber(Position cellPosition, int number, bool numberIsCorrect)
 {
     if (number < 1 || number > 9)
     {
         throw new Exception("SetUserNumber() - Number out of range.");
     }
     else if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("SetUserNumber() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("SetUserNumber() - Column index out of range.");
     }
     else
     {
         return m_gridSquares[cellPosition.Row, cellPosition.Column].SetUserNumber(number, numberIsCorrect);
     }
 }
コード例 #15
0
        void TheGameBoard_OnCellCleared(int number, Position gridPosition, Position cellPosition)
        {
            if (m_enteringPuzzle)
            {
                int row = gridPosition.Row * 3 + cellPosition.Row;
                int column = gridPosition.Column * 3 + cellPosition.Column;

                TheGameBoard.SolutionGrid[row, column] = 0;
            }

            NumberSelectionPanel.UpdateNumberCount(TheGameBoard.SuppliedNumberCount);
        }
コード例 #16
0
 public int GridCellValue(Position gridPosition, Position cellPosition)
 {
     if (gridPosition.Row < 0 || gridPosition.Row > 2)
     {
         throw new Exception("GridCellValue() - Row index out of range.");
     }
     else if (gridPosition.Column < 0 || gridPosition.Column > 2)
     {
         throw new Exception("GridCellValue() - Column index out of range.");
     }
     else
     {
         return m_theGrids[gridPosition.Row, gridPosition.Column].CellValue(cellPosition);
     }
 }
コード例 #17
0
        private void TheGameBoard_OnCellTapped(Position gridPosition, Position cellPosition)
        {
            if (m_enteringPuzzle)
            {
                int row = gridPosition.Row * 3 + cellPosition.Row;
                int column = gridPosition.Column * 3 + cellPosition.Column;

                TheGameBoard.SolutionGrid[row, column] = TheGameBoard.NumberSelected;
            }
            else
            {
                NumberSelectionPanel.UpdateNumberCount(TheGameBoard.SuppliedNumberCount);

                if (IsSolutionCorrect())
                {
                    m_gameActive = false;
                    PauseToolStripButton.Enabled = false;

                    SaveHallOfFameEntry();
                }
            }
        }
 public void ClearNumber(Position cellPosition)
 {
     if (cellPosition.Row < 0 || cellPosition.Row > 2)
     {
         throw new Exception("ClearNumber() - Row index out of range.");
     }
     else if (cellPosition.Column < 0 || cellPosition.Column > 2)
     {
         throw new Exception("ClearNumber() - Column index out of range.");
     }
     else
     {
         m_gridSquares[cellPosition.Row, cellPosition.Column].ClearCell();
     }
 }