Beispiel #1
0
 //public void row_checker(int x,string left_or_right)
 //{
 //    for (int index = 0; index < gomb_place.GetLength(0)-1; index++)
 //    {
 //        if (left_or_right == "right")
 //        {
 //            for (int i = 1; i < gomb_place.GetLength(1); i++)
 //            {
 //                if (gomb_place[x, i - 1] == 1 && gomb_place[x, i] == 0)
 //                {
 //                    change_buttons(x, i, x, i - 1);
 //                }
 //            }
 //        }
 //        if (left_or_right == "left")
 //        {
 //            for (int i = 1; i < gomb_place.GetLength(1); i++)
 //            {
 //                if (gomb_place[x, i - 1] == 0 && gomb_place[x, i] == 1)
 //                {
 //                    change_buttons(x, i - 1, x, i);
 //                }
 //            }
 //        }
 //    }
 //}
 //public void coloumn_checker(int y,string top_or_down)
 //{
 //    for (int index = 0; index < gomb_place.GetLength(1)-1; index++)
 //    {
 //        if (top_or_down == "up")
 //        {
 //            int i = 1;
 //            while (i < gomb_place.GetLength(0))
 //            {
 //                if (gomb_place[i - 1, y] == 0 && gomb_place[i, y] == 1)
 //                {
 //                    change_buttons(i - 1, y, i, y);
 //                }
 //                i++;
 //            }
 //        }
 //        if (top_or_down == "down")
 //        {
 //            int i = 1;
 //            while (i < gomb_place.GetLength(0))
 //            {
 //                if (gomb_place[i - 1, y] == 1 && gomb_place[i, y] == 0)
 //                {
 //                    change_buttons(i, y, i - 1, y);
 //                }
 //                i++;
 //            }
 //        }
 //    }
 //}
 private void reset_game(bool needBeginGameButton)
 {
     _saveGameArea.delete_this_side(_aSide);
     for (var i = 0; i < _gombPlace.GetLength(0); i++)
     {
         for (var j = 0; j < _gombPlace.GetLength(1); j++)
         {
             _gombPlace[i, j] = 0;
         }
     }
     for (var i = 0; i < _gameButtons.GetLength(0); i++)
     {
         for (var j = 0; j < _gameButtons.GetLength(1); j++)
         {
             GameButton.normal_btn(_gameButtons[i, j]);
         }
     }
     _informationContainer.reset_Score();
     if (!needBeginGameButton)
     {
         return;
     }
     add_new_number(2);
     add_new_number(2);
 }
Beispiel #2
0
        public void get_last_scene()
        {
            //   reset_game(false);
            var sum = 0;

            for (var i = 0; i < _lastPlaces.GetLength(0); i++)
            {
                for (var j = 0; j < _lastPlaces.GetLength(1); j++)
                {
                    if (_lastPlaces[i, j] == 1)
                    {
                        _gameButtons[i, j].GetChildAt(0)
                        .SetBackgroundColor(_gameButton.get_color_from_number(_lastValues[i, j]));
                        sum += _lastValues[i, j];
                        _gombPlace[i, j] = 1; //van ott már egy szám
                        GameButton.set_btn_number(_gameButtons[i, j], _lastValues[i, j].ToString());
                    }
                    else
                    {
                        _gombPlace[i, j] = 0;
                        GameButton.normal_btn(_gameButtons[i, j]);
                    }
                }
            }

            _informationContainer.set_score(sum);
        }
Beispiel #3
0
        private void change_buttons(int toNumberX, int toNumberY, int toNormalX, int toNormalY)
        {
            _gombPlace[toNumberX, toNumberY] = 1;
            _gombPlace[toNormalX, toNormalY] = 0;
            var number = GameButton.get_btn_value(_gameButtons[toNormalX, toNormalY]);

            _gameButton.numbered_btn(_gameButtons[toNumberX, toNumberY], int.Parse(number));
            GameButton.normal_btn(_gameButtons[toNormalX, toNormalY]);
        }
Beispiel #4
0
        private void number_fusion(int newPlaceX, int newPlaceY, int emptyPlaceX, int emptyPlaceY)
        {
            _gombPlace[newPlaceX, newPlaceY]     = 1;
            _gombPlace[emptyPlaceX, emptyPlaceY] = 0;
            var number = int.Parse(GameButton.get_btn_value(_gameButtons[newPlaceX, newPlaceY])) +
                         int.Parse(GameButton.get_btn_value(_gameButtons[emptyPlaceX, emptyPlaceY]));

            if (number == 2048)
            {
                win_mess();
            }
            _gameButton.numbered_btn(_gameButtons[newPlaceX, newPlaceY], number);
            GameButton.normal_btn(_gameButtons[emptyPlaceX, emptyPlaceY]);
        }