Example #1
0
        public void up_down_move(string up_or_down, bool fushion_checker)
        {
            was_change = false;
            int sor;

            for (int i = 0; i < gomb_place.GetLength(0); i++)
            {
                for (int proba = 0; proba < gomb_place.GetLength(0) - 1; proba++)
                {
                    if (up_or_down == "up")
                    {
                        sor = 1;
                        while (sor < gomb_place.GetLength(1))
                        {
                            if (gomb_place[sor, i] == 1 && gomb_place[sor - 1, i] == 0)
                            {
                                change_buttons(sor - 1, i, sor, i);
                                was_change = true;
                            }
                            sor++;
                        }
                    }
                    else if (up_or_down == "down")
                    {
                        sor = gomb_place.GetLength(0) - 1;
                        while (sor > 0)
                        {
                            if (gomb_place[sor, i] == 0 && gomb_place[sor - 1, i] == 1)
                            {
                                change_buttons(sor, i, sor - 1, i);
                                was_change = true;
                            }
                            sor--;
                        }
                    }
                }
            }
            if (fushion_checker)
            {
                array_Indexes = new array_indexes[a_side * a_side];
                int array_of_index = 0;
                for (int i = 0; i < gomb_place.GetLength(0); i++)
                {
                    if (up_or_down == "up")
                    {
                        sor = 1;
                        while (sor < gomb_place.GetLength(1))
                        {
                            if ((gomb_place[sor, i] == 1 && gomb_place[sor - 1, i] == 1) && int.Parse(game_Button.get_btn_value(game_Buttons[sor, i])) == int.Parse(game_Button.get_btn_value(game_Buttons[sor - 1, i])))
                            {
                                array_indexes array_ = new array_indexes();
                                array_.to_x      = sor - 1;
                                array_.to_y      = i;
                                array_.from_x    = sor;
                                array_.from_y    = i;
                                array_.direction = "up";
                                array_Indexes[array_of_index] = array_;
                                array_of_index++;
                                sor++;
                            }
                            sor++;
                        }
                    }
                    else if (up_or_down == "down")
                    {
                        sor = gomb_place.GetLength(0) - 1;
                        while (sor > 0)
                        {
                            if ((gomb_place[sor, i] == 1 && gomb_place[sor - 1, i] == 1) && int.Parse(game_Button.get_btn_value(game_Buttons[sor, i])) == int.Parse(game_Button.get_btn_value(game_Buttons[sor - 1, i])))
                            {
                                array_indexes array_ = new array_indexes();
                                array_.to_x      = sor;
                                array_.to_y      = i;
                                array_.from_x    = sor - 1;
                                array_.from_y    = i;
                                array_.direction = "down";
                                array_Indexes[array_of_index] = array_;
                                array_of_index++;
                                sor--;
                            }
                            sor--;
                        }
                    }
                }

                if (was_change || array_of_index > 0)
                {
                    add_new_number(2);
                }
                frame_fushion(array_Indexes, array_of_index);
            }
        }
Example #2
0
 public void left_right_move(string right_or_left, bool frame_checker)
 {
     was_change = false;
     for (int i = 0; i < gomb_place.GetLength(0); i++)
     {
         for (int proba = 0; proba < gomb_place.GetLength(0) - 1; proba++)
         {
             if (right_or_left == "left")
             {
                 for (int j = 1; j < gomb_place.GetLength(1); j++)
                 {
                     if (gomb_place[i, j - 1] == 0 && gomb_place[i, j] == 1)
                     {
                         change_buttons(i, j - 1, i, j);
                         was_change = true;
                     }
                 }
             }
             else if (right_or_left == "right")
             {
                 for (int j = gomb_place.GetLength(1) - 1; j >= 1; j--)
                 {
                     if (gomb_place[i, j] == 0 && gomb_place[i, j - 1] == 1)
                     {
                         change_buttons(i, j, i, j - 1);
                         was_change = true;
                     }
                 }
             }
         }
     }
     if (frame_checker)
     {
         array_Indexes = new array_indexes[a_side * a_side];
         int array_of_index = 0;
         for (int i = 0; i < gomb_place.GetLength(0); i++)
         {
             if (right_or_left == "left")
             {
                 for (int j = 1; j < gomb_place.GetLength(1); j++)
                 {
                     if ((gomb_place[i, j - 1] == 1 && gomb_place[i, j] == 1) && (int.Parse(game_Button.get_btn_value(game_Buttons[i, j - 1])) == int.Parse(game_Button.get_btn_value(game_Buttons[i, j]))))
                     {
                         array_indexes array_ = new array_indexes();
                         array_.to_x      = i;
                         array_.to_y      = j - 1;
                         array_.from_x    = i;
                         array_.from_y    = j;
                         array_.direction = "left";
                         array_Indexes[array_of_index] = array_;
                         array_of_index++;
                         j++;
                     }
                 }
             }
             else if (right_or_left == "right")
             {
                 for (int j = gomb_place.GetLength(1) - 1; j >= 1; j--)
                 {
                     if (gomb_place[i, j] == 1 && gomb_place[i, j - 1] == 1 && (int.Parse(game_Button.get_btn_value(game_Buttons[i, j - 1])) == int.Parse(game_Button.get_btn_value(game_Buttons[i, j]))))
                     {
                         array_indexes array_ = new array_indexes();
                         array_.to_x      = i;
                         array_.to_y      = j;
                         array_.from_x    = i;
                         array_.from_y    = j - 1;
                         array_.direction = "right";
                         array_Indexes[array_of_index] = array_;
                         array_of_index++;
                         j--;
                     }
                 }
             }
         }
         if (was_change || array_of_index > 0)
         {
             add_new_number(2);
         }
         frame_fushion(array_Indexes, array_of_index);
     }
 }