Exemplo n.º 1
0
 public Easy_Form(EasyData ED)
 {
     this.ED                   = ED;
     summation_matrix          = ED.easy_summation_matrix;
     should_display_number     = ED.should_display_number;
     initially_displayed       = ED.initially_displayed;
     right_edge                = ED.easy_right_edge;
     bottom_edge               = ED.easy_bottom_edge;
     custom_summation_matrix   = ED.easy_custom_summation_matrix;
     original_summation_matrix = ED.easy_original_summation_matrix;
     custom_bottom_edge        = ED.easy_custom_bottom_edge;
     custom_right_edge         = ED.easy_custom_right_edge;
     Easy_White_Pen            = new Pen(Color.White);
     InitializeComponent();
 }
Exemplo n.º 2
0
        /********************************************************************************
         *
         * Method: Back_Button_Click
         *
         * Arguments: object sender, EventArgs e
         *
         * Return Type: void
         *
         * Purpose: Saves the game upon going back.
         *
         * *******************************************************************************/
        private void Back_Button_Click(object sender, EventArgs e)
        {
            ED = new EasyData();

            ED.easy_summation_matrix = summation_matrix;
            ED.should_display_number = should_display_number;
            ED.initially_displayed   = initially_displayed;

            ED.easy_right_edge  = right_edge;
            ED.easy_bottom_edge = bottom_edge;

            ED.easy_custom_summation_matrix = custom_summation_matrix;

            ED.easy_custom_right_edge  = custom_right_edge;
            ED.easy_custom_bottom_edge = custom_bottom_edge;

            Form1 form1 = new Form1(ED);

            Easy_Form Easy_Form = new Easy_Form(ED);

            form1.Show();
            this.Hide();
            Easy_Form.Close();
        }
Exemplo n.º 3
0
 /********************************************************************************
  *
  * Constructor: Form1
  *
  * Arguments: EasyData ED
  *
  * *******************************************************************************/
 public Form1(EasyData ED)
 {
     easyData1  = ED;
     myWhitePen = new Pen(Color.White);
     InitializeComponent();
 }
Exemplo n.º 4
0
        public Form1()
        {
            easyData1           = new EasyData();
            easyData1.startTime = DateTime.Now.Millisecond;

            mediumData1           = new MediumData();
            mediumData1.startTime = DateTime.Now.Millisecond;

            hardData1           = new HardData();
            hardData1.startTime = DateTime.Now.Millisecond;

            myWhitePen = new Pen(Color.White);

            string easy_file = "";
            string med_file  = "";
            string hard_file = "";

            Random random    = new Random();
            int    easy_rand = random.Next(3);
            int    med_rand  = random.Next(3);
            int    hard_rand = random.Next(3);

            #region File Choice
            switch (easy_rand)
            {
            case 0:
                easy_file = "easy/e1.txt";
                break;

            case 1:
                easy_file = "easy/e2.txt";
                break;

            case 2:
                easy_file = "easy/e2.txt";
                break;
            }
            switch (med_rand)
            {
            case 0:
                med_file = "medium/m1.txt";
                break;

            case 1:
                med_file = "medium/m2.txt";
                break;

            case 2:
                med_file = "medium/m2.txt";
                break;
            }
            switch (hard_rand)
            {
            case 0:
                hard_file = "hard/h1.txt";
                break;

            case 1:
                hard_file = "hard/h1.txt";
                break;

            case 2:
                hard_file = "hard/h1.txt";
                break;
            }
            #endregion

            // EASY Read
            #region Easy Read
            string easy_digits = "0123456789";

            StringBuilder easy_file_data_builder = new StringBuilder();
            StringBuilder easy_solution          = new StringBuilder();

            using (StreamReader easy_inFile = new StreamReader(easy_file))
            {
                while (!easy_inFile.EndOfStream)
                {
                    char ch = (char)easy_inFile.Read();
                    if (easy_digits.IndexOf(ch) == -1)
                    {
                        easy_file_data_builder.Append('$');
                        if (easy_file_data_builder.Equals("$$"))
                        {
                        }
                    }
                    else
                    {
                        easy_file_data_builder.Append(ch);
                    }
                }
            }

            StringBuilder easy_digitsOnly = new StringBuilder();

            foreach (char cha in easy_file_data_builder.ToString().ToCharArray())
            {
                if (easy_digits.IndexOf(cha) >= 0)
                {
                    easy_digitsOnly.Append(cha);
                }
            }

            char[] easy_file_chars = easy_digitsOnly.ToString().ToCharArray();

            int easy_len = easy_file_chars.Length;

            int easy_r = 0;

            while (easy_r < easy_len)
            {
                if (easy_r < easy_len / 2)
                {
                    if (easy_file_chars[easy_r] > 48)
                    {
                        easyData1.initially_displayed[easy_r / 3, easy_r % 3] = true;
                    }
                    easyData1.easy_custom_summation_matrix[easy_r / 3, easy_r % 3] = easy_file_chars[easy_r] - 48;
                }
                else
                {
                    int easy_t = easy_r - (easy_len / 2);
                    easyData1.easy_summation_matrix[easy_t / 3, easy_t % 3] = easy_file_chars[easy_r] - 48;
                }
                easy_r++;
            }
            #endregion

            // MEDIUM Read
            #region Medium Read
            string med_digits = "0123456789";

            StringBuilder med_file_data_builder = new StringBuilder();
            StringBuilder med_solution          = new StringBuilder();

            using (StreamReader med_inFile = new StreamReader(med_file))
            {
                while (!med_inFile.EndOfStream)
                {
                    char ch = (char)med_inFile.Read();
                    if (med_digits.IndexOf(ch) == -1)
                    {
                        med_file_data_builder.Append('$');
                        if (med_file_data_builder.Equals("$$"))
                        {
                        }
                    }
                    else
                    {
                        med_file_data_builder.Append(ch);
                    }
                }
            }

            StringBuilder med_digitsOnly = new StringBuilder();

            foreach (char cha in med_file_data_builder.ToString().ToCharArray())
            {
                if (med_digits.IndexOf(cha) >= 0)
                {
                    med_digitsOnly.Append(cha);
                }
            }

            char[] med_file_chars = med_digitsOnly.ToString().ToCharArray();

            int med_len = med_file_chars.Length;

            int med_r = 0;

            while (med_r < med_len)
            {
                if (med_r < med_len / 2)
                {
                    if (med_file_chars[med_r] > 48)
                    {
                        mediumData1.initially_displayed[med_r / 5, med_r % 5] = true;
                    }

                    mediumData1.medium_custom_summation_matrix[med_r / 5, med_r % 5] = med_file_chars[med_r] - 48;

                    mediumData1.medium_original_summation_matrix[med_r / 5, med_r % 5] = med_file_chars[med_r] - 48;
                }
                else
                {
                    int med_t = med_r - (med_len / 2);
                    mediumData1.medium_summation_matrix[med_t / 5, med_t % 5] = med_file_chars[med_r] - 48;
                }
                med_r++;
            }
            #endregion

            // HARD Read
            #region Hard Read
            string hard_digits = "0123456789";

            StringBuilder hard_file_data_builder = new StringBuilder();
            StringBuilder hard_solution          = new StringBuilder();


            using (StreamReader hard_inFile = new StreamReader(hard_file))
            {
                while (!hard_inFile.EndOfStream)
                {
                    char ch = (char)hard_inFile.Read();
                    if (hard_digits.IndexOf(ch) == -1)
                    {
                        hard_file_data_builder.Append('$');
                        if (hard_file_data_builder.Equals("$$"))
                        {
                        }
                    }
                    else
                    {
                        hard_file_data_builder.Append(ch);
                    }
                }
            }

            StringBuilder hard_digitsOnly = new StringBuilder();

            foreach (char cha in hard_file_data_builder.ToString().ToCharArray())
            {
                if (hard_digits.IndexOf(cha) >= 0)
                {
                    hard_digitsOnly.Append(cha);
                }
            }

            char[] hard_file_chars = hard_digitsOnly.ToString().ToCharArray();

            int hard_len = hard_file_chars.Length;

            int hard_r = 0;

            while (hard_r < hard_len)
            {
                if (hard_r < hard_len / 2)
                {
                    if (hard_file_chars[hard_r] > 48)
                    {
                        hardData1.initially_displayed[hard_r / 7, hard_r % 7] = true;
                    }

                    hardData1.hard_custom_summation_matrix[hard_r / 7, hard_r % 7] = hard_file_chars[hard_r] - 48;

                    hardData1.hard_original_summation_matrix[hard_r / 7, hard_r % 7] = hard_file_chars[hard_r] - 48;
                }
                else
                {
                    int hard_t = hard_r - (hard_len / 2);
                    hardData1.hard_summation_matrix[hard_t / 7, hard_t % 7] = hard_file_chars[hard_r] - 48;
                }
                hard_r++;
            }
            #endregion
            InitializeComponent();
        }
Exemplo n.º 5
0
        /********************************************************************************
         *
         * Method: InitializeEasyData
         *
         * Arguments:
         *
         * Return Type: void
         *
         * Purpose: Initializes all easy files and reloads them.
         *
         * *******************************************************************************/
        public void InitializeEasyData()
        {
            if (easyData1 == null)
            {
                easyData1 = new EasyData();
                Random random    = new Random();
                string easy_file = "";
                int    easy_rand = random.Next(3);

                switch (easy_rand)
                {
                case 0:
                    easy_file = "easy/e1.txt";
                    break;

                case 1:
                    easy_file = "easy/e2.txt";
                    break;

                case 2:
                    easy_file = "easy/e1.txt";
                    break;
                }

                // EASY
                string easy_digits = "0123456789";

                StringBuilder easy_file_data_builder = new StringBuilder();
                StringBuilder easy_solution          = new StringBuilder();

                using (StreamReader easy_inFile = new StreamReader(easy_file))
                {
                    while (!easy_inFile.EndOfStream)
                    {
                        char ch = (char)easy_inFile.Read();
                        if (easy_digits.IndexOf(ch) == -1)
                        {
                            easy_file_data_builder.Append('$');
                            if (easy_file_data_builder.Equals("$$"))
                            {
                            }
                        }
                        else
                        {
                            easy_file_data_builder.Append(ch);
                        }
                    }
                }

                StringBuilder easy_digitsOnly = new StringBuilder();

                foreach (char cha in easy_file_data_builder.ToString().ToCharArray())
                {
                    if (easy_digits.IndexOf(cha) >= 0)
                    {
                        easy_digitsOnly.Append(cha);
                    }
                }

                char[] easy_file_chars = easy_digitsOnly.ToString().ToCharArray();

                int easy_len = easy_file_chars.Length;

                int easy_r = 0;

                while (easy_r < easy_len)
                {
                    if (easy_r < easy_len / 2)
                    {
                        if (easy_file_chars[easy_r] > 48)
                        {
                            easyData1.initially_displayed[easy_r / 3, easy_r % 3] = true;
                        }
                        easyData1.easy_custom_summation_matrix[easy_r / 3, easy_r % 3] = easy_file_chars[easy_r] - 48;
                    }
                    else
                    {
                        int easy_t = easy_r - (easy_len / 2);
                        easyData1.easy_summation_matrix[easy_t / 3, easy_t % 3] = easy_file_chars[easy_r] - 48;
                    }
                    easy_r++;
                }
            }
        }
Exemplo n.º 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);
            }
        }