Exemple #1
0
        /********************************************************************************
         *
         * Method: ProgressButton_Click
         *
         * Arguments: object sender, EventArgs e
         *
         * Return Type: void
         *
         * Purpose: Shows game progress.
         *
         * *******************************************************************************/
        private void ProgressButton_Click(object sender, EventArgs e)
        {
            int      width  = Hard_Playing_Field.Width;
            int      height = Hard_Playing_Field.Height;
            Graphics g      = Hard_Playing_Field.CreateGraphics();

            string[] numbers_array = new string[100];

            for (int x = 0; x < 7; x++)
            {
                for (int y = 0; y < 7; y++)
                {
                    if (custom_summation_matrix[y, x] > 0 && custom_summation_matrix[y, x] != summation_matrix[y, x])
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            numbers_array[i] = i.ToString();
                            // Required for erasing
                            g.DrawString(numbers_array[i], draw_Font_14_Bold, Hard_Black_Brush, (x * (width / 8)) + 3, (y * (height / 8)) + 3);
                            g.DrawString(numbers_array[i], input_Font_14, Hard_Black_Brush, (x * (width / 8)) + 3, (y * (height / 8)) + 3);
                        }
                        g.DrawString(custom_summation_matrix[y, x] + "", input_Font_14, Hard_Default_White_Brush, (x * (width / 8)) + 3, (y * (height / 8)) + 3);
                    }
                }
            }
        }
Exemple #2
0
        //private void HardTimerTextBox_TextChanged(object sender, EventArgs e)
        //{
        //    HardTimerTextBox.Text = StartTimer();
        //}
        //string StartTimer()
        //{
        //    Hard_Timer = new System.Windows.Forms.Timer();
        //    Hard_Timer.Interval = 1000;
        //    Hard_Timer.Tick += new EventHandler(HardTimerTextBox_TextChanged);
        //    Hard_Timer.Enabled = true;
        //    Hard_Timer.Start();

        //    stopWatch.Start();
        //    TimeSpan ts = stopWatch.Elapsed;

        //    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}",
        //    ts.Hours, ts.Minutes, ts.Seconds);

        //    return elapsedTime;
        //}

        /********************************************************************************
         *
         * Method: Reset_Button_Click
         *
         * Arguments: object sender, EventArgs e
         *
         * Return Type: void
         *
         * Purpose: Resets the game.
         *
         * *******************************************************************************/
        private void Reset_Button_Click(object sender, EventArgs e)
        {
            int[,] original_custom_summation_matrix = new int[8, 8];
            Graphics   g            = Hard_Playing_Field.CreateGraphics();
            SolidBrush paintItBlack = new SolidBrush(Color.Black);

            g.FillRectangle(paintItBlack, 0, 0, Hard_Playing_Field.Width, Hard_Playing_Field.Height);

            int screen_X; int screen_Y;

            for (int x = 0; x < 7; x++)
            {
                screen_X = x * (Hard_Playing_Field.Width / 8);
                for (int y = 0; y < 7; y++)
                {
                    screen_Y = y * (Hard_Playing_Field.Height / 8);

                    if (custom_summation_matrix[y, x] != summation_matrix[y, x])
                    {
                    }
                    else
                    {
                        g.DrawString(custom_summation_matrix[y, x] + "", input_Font_14, Hard_Default_White_Brush, screen_X + 3, screen_Y + 3);
                    }
                }
            }

            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 1 / 8), 0,
                       (Hard_Playing_Field.Width * 1 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 2 / 8), 0,
                       (Hard_Playing_Field.Width * 2 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 3 / 8), 0,
                       (Hard_Playing_Field.Width * 3 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 4 / 8), 0,
                       (Hard_Playing_Field.Width * 4 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 5 / 8), 0,
                       (Hard_Playing_Field.Width * 5 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 6 / 8), 0,
                       (Hard_Playing_Field.Width * 6 / 8), Hard_Playing_Field.Height);
            g.DrawLine(Hard_White_Pen, (Hard_Playing_Field.Width * 7 / 8), 0,
                       (Hard_Playing_Field.Width * 7 / 8), Hard_Playing_Field.Height);

            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 1 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 1 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 2 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 2 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 3 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 3 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 4 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 4 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 5 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 5 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 6 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 6 / 8));
            g.DrawLine(Hard_White_Pen, 0, (Hard_Playing_Field.Height * 7 / 8),
                       Hard_Playing_Field.Width, (Hard_Playing_Field.Height * 7 / 8));
        }
Exemple #3
0
        /********************************************************************************
         *
         * Method: EraseNumbers
         *
         * Arguments: int X, int Y
         *
         * Return Type: void
         *
         * Purpose: Deletes a number from board.
         *
         * *******************************************************************************/
        void EraseNumbers(int X, int Y)
        {
            Graphics g      = Hard_Playing_Field.CreateGraphics();
            int      width  = Hard_Playing_Field.Width;
            int      height = Hard_Playing_Field.Height;

            int[] numbers_array = new int[100];
            for (int i = 0; i < 100; i++)
            {
                numbers_array[i] = i;
                // Required for erasing
                g.DrawString(numbers_array[i].ToString(), draw_Font_14_Bold, Hard_Black_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
                g.DrawString(numbers_array[i].ToString(), input_Font_14, Hard_Black_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
            }
        }
Exemple #4
0
        /********************************************************************************
         *
         * Method: UpdateVisibleGrid
         *
         * Arguments: int x, int y, int number
         *
         * Return Type: void
         *
         * Purpose: Updates the grid.
         *
         * *******************************************************************************/
        private void UpdateVisibleGrid(int x, int y, int number)
        {
            Graphics g = Hard_Playing_Field.CreateGraphics();

            if (x == 7)
            {
                right_edge[y] = number;
            }
            else if (y == 7)
            {
                bottom_edge[x] = number;
            }
            else
            {
                summation_matrix[x, y] = number;
            }

            int screen_X = (x * Hard_Playing_Field.Width) / 8;
            int screen_Y = (y * Hard_Playing_Field.Height) / 8;
        }
Exemple #5
0
        /********************************************************************************
         *
         * Method: LookAtSolution
         *
         * Arguments:
         *
         * Return Type: void
         *
         * Purpose: Compares the game to the end result of the game.
         *
         * *******************************************************************************/
        public void LookAtSolution()
        {
            int screen_X; int screen_Y;

            Graphics g = Hard_Playing_Field.CreateGraphics();

            for (int y = 0; y < 7; y++)
            {
                EraseNumbers(7, y);
            }
            for (int x = 0; x < 7; x++)
            {
                EraseNumbers(x, 7);
            }

            for (int x = 0; x < 7; x++)
            {
                screen_X = 7 * (Hard_Playing_Field.Width / 8);
                int  row_sum         = 0;
                bool all_filled      = true;
                int  desired_row_sum = right_edge[x];
                for (int y = 0; y < 7; y++)
                {
                    row_sum += custom_summation_matrix[x, y];
                    if (custom_summation_matrix[x, y] == 0)
                    {
                        all_filled = false;
                    }
                }
                screen_Y = x * (Hard_Playing_Field.Height / 8);
                g.DrawString(row_sum.ToString(), draw_Font_14_Bold, Hard_Correct_Green_Brush, screen_X + 3, screen_Y + 3);
                if (row_sum > desired_row_sum)
                {
                    DisplayAlert("You entered values too high. Please lower your choices.", "ERROR");
                }
                else if (all_filled && row_sum < desired_row_sum)
                {
                    DisplayAlert("You didn't enter values high enough. Please raise your choices.", "ERROR");
                }
                else if (all_filled && row_sum == desired_row_sum)
                {
                    DisplayAlert("You just solved a row! Congratulations.", "SUCCESS");
                }
            }
            for (int y = 0; y < 7; y++)
            {
                screen_X = (y * (Hard_Playing_Field.Width / 8) + 3);
                screen_Y = (7 * (Hard_Playing_Field.Height / 8) + 3);
                int  col_sum         = 0;
                bool all_filled      = true;
                int  desired_col_sum = bottom_edge[y];
                for (int x = 0; x < 7; x++)
                {
                    col_sum += custom_summation_matrix[x, y];
                    if (custom_summation_matrix[x, y] == 0)
                    {
                        all_filled = false;
                    }
                }
                g.DrawString(col_sum.ToString(), draw_Font_14_Bold, Hard_Correct_Green_Brush, screen_X, screen_Y);
                if (col_sum > desired_col_sum)
                {
                    DisplayAlert("You entered values too high. Please lower your choices.", "ERROR");
                }
                else if (all_filled && col_sum < desired_col_sum)
                {
                    DisplayAlert("You didn't enter values high enough. Please raise your choices.", "ERROR");
                }
                else if (all_filled && col_sum == desired_col_sum)
                {
                    DisplayAlert("You just solved a column! Congratulations.", "SUCCESS");
                }
            }
        }
Exemple #6
0
        /********************************************************************************
         *
         * Method: Update_Hard_Form_Click
         *
         * Arguments: object sender, MouseEventArgs e
         *
         * Return Type: void
         *
         * Purpose: Click function for the game, determines mouse location, calculates edges,
         *           and determines a win.
         *
         * *******************************************************************************/
        private void Update_Hard_Form_Click(object sender, MouseEventArgs e)
        {
            Graphics g = Hard_Playing_Field.CreateGraphics();

            int X      = 0;
            int Y      = 0;
            int width  = Hard_Playing_Field.Width;
            int height = Hard_Playing_Field.Height;

            #region MouseLocator
            if (e.X < width / 8)
            {
                X = 0;
            }
            else if (e.X < ((2 * width) / 8))
            {
                X = 1;
            }
            else if (e.X < ((3 * width) / 8))
            {
                X = 2;
            }
            else if (e.X < ((4 * width) / 8))
            {
                X = 3;
            }
            else if (e.X < ((5 * width) / 8))
            {
                X = 4;
            }
            else if (e.X < ((6 * width) / 8))
            {
                X = 5;
            }
            else if (e.X < ((7 * width) / 8))
            {
                X = 6;
            }
            else
            {
                X = 7;
            }

            if (e.Y < height / 8)
            {
                Y = 0;
            }
            else if (e.Y < ((2 * height) / 8))
            {
                Y = 1;
            }
            else if (e.Y < ((3 * height) / 8))
            {
                Y = 2;
            }
            else if (e.Y < ((4 * height) / 8))
            {
                Y = 3;
            }
            else if (e.Y < ((5 * height) / 8))
            {
                Y = 4;
            }
            else if (e.Y < ((6 * height) / 8))
            {
                Y = 5;
            }
            else if (e.Y < ((7 * height) / 8))
            {
                Y = 6;
            }
            else
            {
                Y = 7;
            }
            #endregion

            if (HardTextBox.Text != "" && Regex.IsMatch(HardTextBox.Text, @"^\d+$") && HardTextBox.Text != "0")
            {
                string[] numbers_array = new string[100];

                int number = Convert.ToInt32(HardTextBox.Text);
                if (!initially_displayed[X, Y])
                {
                    should_display_number[X, Y] = true;
                    if (number >= 1 && number < 100)
                    {
                        // Loop necessary for deletion of every number, in case user changes his mind
                        for (int i = 0; i < 100; i++)
                        {
                            numbers_array[i] = i.ToString();
                            // Required for erasing
                            g.DrawString(numbers_array[i], draw_Font_14_Bold, Hard_Black_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
                            g.DrawString(numbers_array[i], input_Font_14, Hard_Black_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
                        }
                        if (X <= 6 && Y <= 6)
                        {
                            custom_summation_matrix[Y, X] = number;
                            if (summation_matrix[Y, X] == number)
                            {
                                g.DrawString(number.ToString(), input_Font_14, Hard_Correct_Green_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
                                MessageBox.Show("Getting Close!", "HOT", MessageBoxButtons.OK);

                                if (custom_summation_matrix.OfType <int>().SequenceEqual(summation_matrix.OfType <int>()))
                                {
                                    #region
                                    //medium_Timer.Stop();
                                    //stopWatch.Stop();
                                    int completion = random.Next(140);
                                    int time       = 25 + completion;
                                    #endregion

                                    MessageBox.Show("You Won the Game! " + "\n Completion time: " + time + " seconds ", "SUCCESS", MessageBoxButtons.OK);
                                    HD.endTime = DateTime.Now.Millisecond;
                                    HD.solved  = true;
                                    ClearCustomMatrix();
                                    PullUpNewPuzzle();
                                    int timeElapsed = (HD.endTime - HD.startTime) / 1000;
                                    if (HardData.bestTimeEver == 0 || HardData.bestTimeEver > timeElapsed)
                                    {
                                        HardData.bestTimeEver = timeElapsed;
                                    }
                                    HD           = new HardData();
                                    HD.startTime = DateTime.Now.Millisecond;
                                }
                            }
                            else
                            {
                                g.DrawString(number.ToString(), input_Font_14, Hard_Incorrect_Red_Brush, (X * (width / 8)) + 3, (Y * (height / 8)) + 3);
                            }
                            LookAtSolution();
                        }
                    }
                    else
                    {
                        DisplayAlert("You entered too high of a value!", "ERROR");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please make sure to enter integers only.", "ERROR", MessageBoxButtons.OK);
            }
        }