Exemple #1
0
        public DTSudokuFrame(DTSudokuDifficultyValue initialDifficulty)
        {
            this.random = new SudokuRandom();

            this.sudokuBoardFrameSection = null;
            this.sudokuDifficultySelectionFrameSection = new DTSudokuDifficultySelectionFrameSection(initialDifficulty);
            this.sudokuNewGameButtonFrameSection       = new DTSudokuNewGameButtonFrameSection();
            this.sudokuLoadingBoardFrameSection        = new DTSudokuLoadingBoardFrameSection(initialDifficulty, this.random);
        }
Exemple #2
0
        public IFrame <IDTSudokuAssets> GetNextFrame(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput)
        {
            if (this.sudokuLoadingBoardFrameSection == null)
            {
                IMouse translatedMouseInput         = new TranslatedMouse(mouseInput, -25, -25);
                IMouse translatedPreviousMouseInput = new TranslatedMouse(previousMouseInput, -25, -25);

                this.sudokuBoardFrameSection.ProcessInputs(keyboardInput, translatedMouseInput, previousKeyboardInput, translatedPreviousMouseInput);

                IMouse translatedMouseInput2         = new TranslatedMouse(mouseInput, -25, -555);
                IMouse translatedPreviousMouseInput2 = new TranslatedMouse(previousMouseInput, -25, -555);
                this.sudokuDifficultySelectionFrameSection.ProcessInputs(keyboardInput, translatedMouseInput2, previousKeyboardInput, translatedPreviousMouseInput2);

                IMouse translatedMouseInput3         = new TranslatedMouse(mouseInput, -125, -620);
                IMouse translatedPreviousMouseInput3 = new TranslatedMouse(previousMouseInput, -125, -620);
                this.sudokuNewGameButtonFrameSection.ProcessInputs(keyboardInput, translatedMouseInput3, previousKeyboardInput, translatedPreviousMouseInput3);

                if (this.sudokuNewGameButtonFrameSection.HasStartedNewGame())
                {
                    DTSudokuDifficultyValue difficulty = this.sudokuDifficultySelectionFrameSection.GetSelectedDifficulty();

                    this.sudokuLoadingBoardFrameSection = new DTSudokuLoadingBoardFrameSection(difficulty, this.random);
                }
            }
            else
            {
                if (this.sudokuLoadingBoardFrameSection.IsDoneGeneratingSudokuPuzzle())
                {
                    int[,] newBoard = this.sudokuLoadingBoardFrameSection.GetGeneratedSudokuPuzzle();
                    this.sudokuBoardFrameSection        = new DTSudokuBoardFrameSection(newBoard);
                    this.sudokuLoadingBoardFrameSection = null;
                }
                else
                {
                    this.sudokuLoadingBoardFrameSection.KeepGeneratingSudokuPuzzle();
                }
            }

            return(this);
        }
Exemple #3
0
        public DTSudokuLoadingBoardFrameSection(DTSudokuDifficultyValue difficulty, ISudokuRandom random)
        {
            SudokuDifficulty sudokuDifficulty;

            if (difficulty == DTSudokuDifficultyValue.Easy)
            {
                sudokuDifficulty = SudokuDifficulty.Easy;
            }
            else if (difficulty == DTSudokuDifficultyValue.Normal)
            {
                sudokuDifficulty = SudokuDifficulty.Normal;
            }
            else if (difficulty == DTSudokuDifficultyValue.Hard)
            {
                sudokuDifficulty = SudokuDifficulty.Hard;
            }
            else
            {
                throw new Exception();
            }

            this.sudokuGenerator = new SudokuGenerator(new RandomizedSudokuSolver(), random);
            this.sudokuGenerator.StartGeneratingSudokuPuzzle(sudokuDifficulty);
        }
Exemple #4
0
        public void ProcessInputs(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput)
        {
            int x = mouseInput.GetX();
            int y = mouseInput.GetY();

            if (mouseInput.IsLeftMouseButtonPressed() && !previousMouseInput.IsLeftMouseButtonPressed())
            {
                if (y >= 0 && y <= 50)
                {
                    if (x >= 150 && x < 250)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Easy;
                    }
                    if (x >= 250 && x < 350)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Normal;
                    }
                    if (x >= 350 && x < 450)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Hard;
                    }
                }
            }
        }
Exemple #5
0
 public DTSudokuDifficultySelectionFrameSection(DTSudokuDifficultyValue initialDifficulty)
 {
     this.currentlySelectedDifficultyValue = initialDifficulty;
 }