示例#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  = Easy_Playing_Field.Width;
            int      height = Easy_Playing_Field.Height;
            Graphics g      = Easy_Playing_Field.CreateGraphics();

            string[] numbers_array = new string[100];

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; 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, Easy_Black_Brush, (x * (width / 4)) + 12, (y * (height / 4)) + 12);
                            g.DrawString(numbers_array[i], input_Font_14, Easy_Black_Brush, (x * (width / 4)) + 12, (y * (height / 4)) + 12);
                        }
                        g.DrawString(custom_summation_matrix[y, x] + "", input_Font_14, Easy_Default_White_Brush, (x * (width / 4)) + 12, (y * (height / 4)) + 12);
                    }
                }
            }
        }
示例#2
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      = Easy_Playing_Field.CreateGraphics();
            int      width  = Easy_Playing_Field.Width;
            int      height = Easy_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, Easy_Black_Brush, (X * (width / 4)) + 12, (Y * (height / 4)) + 12);
                g.DrawString(numbers_array[i].ToString(), input_Font_14, Easy_Black_Brush, (X * (width / 4)) + 12, (Y * (height / 4)) + 12);
            }
        }
示例#3
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 = Easy_Playing_Field.CreateGraphics();

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

            int screen_X = (x * Easy_Playing_Field.Width) / 4;
            int screen_Y = (y * Easy_Playing_Field.Height) / 4;
        }
示例#4
0
        //private void MediumTimerTextBox_TextChanged(object sender, EventArgs e)
        //{
        //    MediumTimerTextBox.Text = StartTimer();
        //}
        //string StartTimer()
        //{
        //    Easy_Timer = new System.Windows.Forms.Timer();
        //    Easy_Timer.Interval = 1000;
        //    Easy_Timer.Tick += new EventHandler(MediumTimerTextBox_TextChanged);
        //    Easy_Timer.Enabled = true;
        //    Easy_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[4, 4];
            Graphics   g            = Easy_Playing_Field.CreateGraphics();
            SolidBrush paintItBlack = new SolidBrush(Color.Black);

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

            int screen_X; int screen_Y;

            for (int x = 0; x < 3; x++)
            {
                screen_X = x * (Easy_Playing_Field.Width / 4);
                for (int y = 0; y < 3; y++)
                {
                    screen_Y = y * (Easy_Playing_Field.Height / 4);

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

            g.DrawLine(Easy_White_Pen, (Easy_Playing_Field.Width * 1 / 4), 0,
                       (Easy_Playing_Field.Width * 1 / 4), Easy_Playing_Field.Height);
            g.DrawLine(Easy_White_Pen, (Easy_Playing_Field.Width * 2 / 4), 0,
                       (Easy_Playing_Field.Width * 2 / 4), Easy_Playing_Field.Height);
            g.DrawLine(Easy_White_Pen, (Easy_Playing_Field.Width * 3 / 4), 0,
                       (Easy_Playing_Field.Width * 3 / 4), Easy_Playing_Field.Height);

            g.DrawLine(Easy_White_Pen, 0, (Easy_Playing_Field.Height * 1 / 4),
                       Easy_Playing_Field.Width, (Easy_Playing_Field.Height * 1 / 4));
            g.DrawLine(Easy_White_Pen, 0, (Easy_Playing_Field.Height * 2 / 4),
                       Easy_Playing_Field.Width, (Easy_Playing_Field.Height * 2 / 4));
            g.DrawLine(Easy_White_Pen, 0, (Easy_Playing_Field.Height * 3 / 4),
                       Easy_Playing_Field.Width, (Easy_Playing_Field.Height * 3 / 4));
        }
示例#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 = Easy_Playing_Field.CreateGraphics();

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

            for (int x = 0; x < 3; x++)
            {
                screen_X = 3 * (Easy_Playing_Field.Width / 4);
                int  row_sum         = 0;
                bool all_filled      = true;
                int  desired_row_sum = right_edge[x];
                for (int y = 0; y < 3; y++)
                {
                    row_sum += custom_summation_matrix[x, y];
                    if (custom_summation_matrix[x, y] == 0)
                    {
                        all_filled = false;
                    }
                }
                screen_Y = x * (Easy_Playing_Field.Height / 4);
                g.DrawString(row_sum.ToString(), draw_Font_14_Bold, Easy_Correct_Green_Brush, screen_X + 12, screen_Y + 12);
                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 < 3; y++)
            {
                screen_X = (y * (Easy_Playing_Field.Width / 4) + 12);
                screen_Y = (3 * (Easy_Playing_Field.Height / 4) + 12);
                int  col_sum         = 0;
                bool all_filled      = true;
                int  desired_col_sum = bottom_edge[y];
                for (int x = 0; x < 4; 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, Easy_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");
                }
            }
        }
示例#6
0
        /********************************************************************************
         *
         * Method: Update_Easy_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_Easy_Form_Click(object sender, MouseEventArgs e)
        {
            Graphics g = Easy_Playing_Field.CreateGraphics();

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

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

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

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

                int number = Convert.ToInt32(EasyTextBox.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, Easy_Black_Brush, (X * (width / 4)) + 12, (Y * (height / 4)) + 12);
                            g.DrawString(numbers_array[i], input_Font_14, Easy_Black_Brush, (X * (width / 4)) + 12, (Y * (height / 4)) + 12);
                        }
                        if (X <= 2 && Y <= 2)
                        {
                            custom_summation_matrix[Y, X] = number;
                            if (summation_matrix[Y, X] == number)
                            {
                                g.DrawString(number.ToString(), input_Font_14, Easy_Correct_Green_Brush, (X * (width / 4)) + 12, (Y * (height / 4)) + 12);
                                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(10);
                                    int time       = 3 + completion;
                                    #endregion

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