Beispiel #1
0
        private void up_down_move(string upOrDown, bool fushionChecker)
        {
            _wasChange = false;
            int sor;

            for (var i = 0; i < _gombPlace.GetLength(0); i++)
            {
                for (var proba = 0; proba < _gombPlace.GetLength(0) - 1; proba++)
                {
                    switch (upOrDown)
                    {
                    case "up":
                        sor = 1;
                        while (sor < _gombPlace.GetLength(1))
                        {
                            if (_gombPlace[sor, i] == 1 && _gombPlace[sor - 1, i] == 0)
                            {
                                change_buttons(sor - 1, i, sor, i);
                                _wasChange = true;
                            }

                            sor++;
                        }

                        break;

                    case "down":
                        sor = _gombPlace.GetLength(0) - 1;
                        while (sor > 0)
                        {
                            if (_gombPlace[sor, i] == 0 && _gombPlace[sor - 1, i] == 1)
                            {
                                change_buttons(sor, i, sor - 1, i);
                                _wasChange = true;
                            }

                            sor--;
                        }

                        break;
                    }
                }
            }

            if (!fushionChecker)
            {
                return;
            }
            {
                _arrayIndexes = new ArrayIndexes[_aSide * _aSide];
                var arrayOfIndex = 0;
                for (var i = 0; i < _gombPlace.GetLength(0); i++)
                {
                    switch (upOrDown)
                    {
                    case "up":
                        sor = 1;
                        while (sor < _gombPlace.GetLength(1))
                        {
                            if (_gombPlace[sor, i] == 1 && _gombPlace[sor - 1, i] == 1 &&
                                int.Parse(GameButton.get_btn_value(_gameButtons[sor, i])) ==
                                int.Parse(GameButton.get_btn_value(_gameButtons[sor - 1, i])))
                            {
                                var array = new ArrayIndexes
                                {
                                    ToX       = sor - 1,
                                    ToY       = i,
                                    FromX     = sor,
                                    FromY     = i,
                                    Direction = "up"
                                };
                                _arrayIndexes[arrayOfIndex] = array;
                                arrayOfIndex++;
                                sor++;
                            }

                            sor++;
                        }

                        break;

                    case "down":
                        sor = _gombPlace.GetLength(0) - 1;
                        while (sor > 0)
                        {
                            if (_gombPlace[sor, i] == 1 && _gombPlace[sor - 1, i] == 1 &&
                                int.Parse(GameButton.get_btn_value(_gameButtons[sor, i])) ==
                                int.Parse(GameButton.get_btn_value(_gameButtons[sor - 1, i])))
                            {
                                var array = new ArrayIndexes
                                {
                                    ToX       = sor,
                                    ToY       = i,
                                    FromX     = sor - 1,
                                    FromY     = i,
                                    Direction = "down"
                                };
                                _arrayIndexes[arrayOfIndex] = array;
                                arrayOfIndex++;
                                sor--;
                            }

                            sor--;
                        }

                        break;
                    }
                }

                if (_wasChange || arrayOfIndex > 0 && is_place_for_btn())
                {
                    add_new_number(GameButton.get_new_btn());
                }
                frame_fushion(_arrayIndexes, arrayOfIndex);
            }
        }
Beispiel #2
0
        private void left_right_move(string rightOrLeft, bool frameChecker)
        {
            _wasChange = false;
            for (var i = 0; i < _gombPlace.GetLength(0); i++)
            {
                for (var proba = 0; proba < _gombPlace.GetLength(0) - 1; proba++)
                {
                    if (rightOrLeft == "left")
                    {
                        for (var k = 1; k < _gombPlace.GetLength(1); k++)
                        {
                            if (_gombPlace[i, k - 1] == 0 && _gombPlace[i, k] == 1)
                            {
                                change_buttons(i, k - 1, i, k);
                                _wasChange = true;
                            }
                            else if (rightOrLeft == "right")
                            {
                                for (var j = _gombPlace.GetLength(1) - 1; j >= 1; j--)
                                {
                                    if (_gombPlace[i, j] == 0 && _gombPlace[i, j - 1] == 1)
                                    {
                                        change_buttons(i, j, i, j - 1);
                                        _wasChange = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (!frameChecker)
            {
                return;
            }
            {
                _arrayIndexes = new ArrayIndexes[_aSide * _aSide];
                var arrayOfIndex = 0;
                for (var i = 0; i < _gombPlace.GetLength(0); i++)
                {
                    if (rightOrLeft == "left")
                    {
                        for (var k = 1; k < _gombPlace.GetLength(1); k++)
                        {
                            if (_gombPlace[i, k - 1] == 1 && _gombPlace[i, k] == 1 &&
                                int.Parse(GameButton.get_btn_value(_gameButtons[i, k - 1])) ==
                                int.Parse(GameButton.get_btn_value(_gameButtons[i, k])))
                            {
                                var array = new ArrayIndexes
                                {
                                    ToX       = i,
                                    ToY       = k - 1,
                                    FromX     = i,
                                    FromY     = k,
                                    Direction = "left"
                                };
                                _arrayIndexes[arrayOfIndex] = array;
                                arrayOfIndex++;
                                k++;
                            }
                            else if (rightOrLeft == "right")
                            {
                                for (var j = _gombPlace.GetLength(1) - 1; j >= 1; j--)
                                {
                                    if (_gombPlace[i, j] == 1 && _gombPlace[i, j - 1] == 1 &&
                                        int.Parse(GameButton.get_btn_value(_gameButtons[i, j - 1])) ==
                                        int.Parse(GameButton.get_btn_value(_gameButtons[i, j])))
                                    {
                                        var array = new ArrayIndexes
                                        {
                                            ToX       = i,
                                            ToY       = j,
                                            FromY     = j - 1,
                                            FromX     = i,
                                            Direction = "right"
                                        };
                                        _arrayIndexes[arrayOfIndex] = array;
                                        arrayOfIndex++;
                                        j--;
                                    }
                                }
                            }
                        }
                    }
                }

                if (_wasChange || arrayOfIndex > 0 && is_place_for_btn())
                {
                    add_new_number(GameButton.get_new_btn());
                }
                frame_fushion(_arrayIndexes, arrayOfIndex);
            }
        }