Пример #1
0
        // 6ai) get_random_letter(square, point_group) - gets a random
        // letter from the chosen group
        //      adds this letters to square.letter
        public static void Get(
            NonStaticClasses.LetterSquare _square, List <string> _letterGroup)
        {
            Int32 tmp_random = GameStatus.Settings.Rnd.Next(_letterGroup.Count);

            _square.Letter = _letterGroup[tmp_random];
        }
Пример #2
0
 // 4) create_letters_boxes() - creates all LetterSquare objects
 // and place into 2d array [col,row]
 public static void CreateBoxes()
 {
     NonStaticClasses.LetterSquare[,] _full_array = new NonStaticClasses.LetterSquare[
         Styling.GameGrid.LettersWide,
         Styling.GameGrid.LettersHigh];
     for (Int32 row = 0; row < Styling.GameGrid.LettersWide; row++)
     {
         for (Int32 col = 0; col < Styling.GameGrid.LettersHigh; col++)
         {
             NonStaticClasses.LetterSquare tmp_new = new NonStaticClasses.LetterSquare(col + 1, row + 1);
             _full_array[col, row] = tmp_new;
         }
     }
     TrackerVariables.TrackedVariables.FullGrid = _full_array;
 }
        // 6a) get_random_letter_group(square) - gets a random int
        // between 1 and 1506
        //     uses this to choose which letter group to use
        //     calls 6ai) get_random_letter(square, point_group)
        public static void Get(NonStaticClasses.LetterSquare _square)
        {
            Int32         _tmpRandom         = GameStatus.Settings.Rnd.Next(1, 151);
            List <string> _chosenLetterGroup = new List <string>();

            switch (_tmpRandom)
            {
            case int n when n > 0 && n <= 60:
                _chosenLetterGroup = Content.Letters.OnePoint;
                break;

            case int n when n > 60 && n <= 90:
                _chosenLetterGroup = Content.Letters.TwoPoints;
                break;

            case int n when n > 90 && n <= 110:
                _chosenLetterGroup = Content.Letters.ThreePoints;
                break;

            case int n when n > 110 && n <= 125:
                _chosenLetterGroup = Content.Letters.FourPoints;
                break;

            case int n when n > 125 && n <= 137:
                _chosenLetterGroup = Content.Letters.FivePoints;
                break;

            case int n when n > 137 && n <= 145:
                _chosenLetterGroup = Content.Letters.EightPoints;
                break;

            case int n when n > 145:
                _chosenLetterGroup = Content.Letters.TenPoints;
                break;

            default:
                break;
            }
            if (_chosenLetterGroup.Count > 0)
            {
                Methods.GameGridCreation.GetRandomLetters.Get(_square, _chosenLetterGroup);
            }
        }
Пример #4
0
 // WHEN TO TURN OFF THE SELECTED
 public static void GetColours(NonStaticClasses.LetterSquare _lettersquare)
 {
     if (_lettersquare.Highlight == true)
     {
         _lettersquare.BackgroundColour = Styling.GameGrid.ColourGridBoxHighlight;
         _lettersquare.TextColour       = Styling.GameGrid.ColourGridTextHighlight;
     }
     else if (_lettersquare.Selected == true)
     {
         _lettersquare.BackgroundColour = Styling.GameGrid.ColourGridBoxSelected;
         _lettersquare.TextColour       = Styling.GameGrid.ColourGridTextSelected;
     }
     else if (_lettersquare.Found)
     {
         _lettersquare.BackgroundColour = Styling.GameGrid.ColourGridBoxFound;
         _lettersquare.TextColour       = Styling.GameGrid.ColourGridTextFound;
     }
     else
     {
         _lettersquare.BackgroundColour = Styling.GameGrid.ColourGridBox;
         _lettersquare.TextColour       = Styling.GameGrid.ColourGridText;
     }
 }
Пример #5
0
        // checks all currently selected squares to makes sures they are in
        // the same row, col or diagonal as the currently clicked square,
        // if they are not they are reset back to original style
        // PROBLEM AS THIS IS HARDCODED!?!?
        // if they are then they are added to temp list and this list
        // becomes the selected_list
        // NEW Way - only compare with the last clicked square
        // if in same row, column or diagonal then this is the only
        // acceptible grids any selected_list not in that row deselected
        public static void ResetColours(NonStaticClasses.LetterSquare _grid)
        {
            double tmp_x_direction;
            double tmp_y_direction;
            double tmp_gradient;


            if (TrackerVariables.TrackedVariables.SelectedLetters.Count > 1)
            {
                // get most recent last click now
                // cv.get_last_clicked();
                tmp_x_direction = TrackerVariables.TrackedVariables.LastClickedLetter.Col - _grid.Col;
                tmp_y_direction = TrackerVariables.TrackedVariables.LastClickedLetter.Row - _grid.Row;
                if (tmp_x_direction == 0)
                {
                    // Vertical
                    foreach (NonStaticClasses.LetterSquare _grid2 in TrackerVariables.TrackedVariables.SelectedLetters.ToList())
                    {
                        //if ((grid.col - test_grid.col != 0) &&
                        //    grid.found == false)
                        if (_grid2.Col - _grid.Col != 0)
                        {
                            _grid2.Selected = false;
                        }
                    }
                }
                else if (tmp_y_direction == 0)
                {
                    // Horizontal
                    foreach (NonStaticClasses.LetterSquare _grid3 in TrackerVariables.TrackedVariables.SelectedLetters.ToList())
                    {
                        if ((_grid3.Row - _grid.Row != 0) &&
                            _grid3.Found == false)
                        {
                            _grid3.Selected = false;
                        }
                    }
                }
                else
                {
                    tmp_gradient = tmp_x_direction / tmp_y_direction;
                    if (tmp_gradient == 1 || tmp_gradient == -1)
                    {
                        // Diagonal down?
                        foreach (NonStaticClasses.LetterSquare _grid4 in TrackerVariables.TrackedVariables.SelectedLetters.ToList())
                        {
                            if (_grid4.Col == _grid.Col &&
                                _grid4.Row == _grid.Row)
                            {
                                // Ignore if its comparing itself
                                break;
                            }
                            else if (_grid4.Col - _grid.Col == 0 ^
                                     _grid4.Row - _grid.Row == 0)
                            {
                                // if in same row or same column (NOT BOTH)
                                _grid4.Selected = false;
                            }
                            // Convert to double as will not calculate decimals
                            // otherwise
                            else if (
                                (Convert.ToDouble(_grid4.Col) - _grid.Col) /
                                (_grid4.Row - _grid.Row) != tmp_gradient)
                            {
                                // if not in diagonal
                                _grid4.Selected = false;
                            }
                        }
                    }
                    else
                    {
                        // Not in same line, diag or column
                        foreach (NonStaticClasses.LetterSquare _grid5 in TrackerVariables.TrackedVariables.SelectedLetters.ToList())
                        {
                            _grid5.Selected = false;
                            // does this turn them all off including the
                            // clicked one
                        }
                    }
                }
            }
        }
Пример #6
0
        // Turn on all the grids between the clicked grid and the others
        // in same row, column or diag
        public static void AutoSelect()
        {
            // Find the highest and lowest row or col first of last clicked
            // and one before
            NonStaticClasses.LetterSquare _firstClick = TrackerVariables.TrackedVariables.SelectedLetters[
                                       TrackerVariables.TrackedVariables.SelectedLetters.Count - 2];
            NonStaticClasses.LetterSquare _secondClick = TrackerVariables.TrackedVariables.SelectedLetters[
                                        TrackerVariables.TrackedVariables.SelectedLetters.Count - 1];

            Int32 _startX = TrackerVariables.TrackedVariables.SelectedLetters.Min(x => x.Col) - 1;
            Int32 _endX = TrackerVariables.TrackedVariables.SelectedLetters.Max(x => x.Col) - 1;
            Int32 _startY = TrackerVariables.TrackedVariables.SelectedLetters.Min(y => y.Row - 1);
            Int32 _endY = TrackerVariables.TrackedVariables.SelectedLetters.Max(y => y.Row - 1);

            if (_startX == _endX) // Vertical 
            {
                for (int _start = _startY + 1; _start < _endY; _start++)
                {
                    if (TrackerVariables.TrackedVariables.FullGrid[_startX, _start].Selected ==
                            false)
                    {
                        TrackerVariables.TrackedVariables.FullGrid[_startX, _start].Selected =
                            false;
                    }
                }
            }
            else if (_startY == _endY) // Horizontal
            {
                for (int _start = _startX + 1; _start < _endX; _start++)
                {
                    if (TrackerVariables.TrackedVariables.FullGrid[_start, _startY].Selected ==
                            false)
                    {
                        TrackerVariables.TrackedVariables.FullGrid[_start, _startY].Selected =
                            true;
                    }
                }
            }
            else
            {
                // Diagonal
                // Get gradient
                // IS THIS CALCULATING A DECIMAL??
                float _gradient = (_firstClick.Col - _secondClick.Col) /
                                 (_firstClick.Row - _secondClick.Row);
                if (_gradient == 1) // Diagonally down
                {
                    for (int _increase = 1;
                         _increase < _endX - _startX;
                         _increase++)
                    {
                        if (TrackerVariables.TrackedVariables.FullGrid[(_startX + _increase),
                            (_startY + _increase)].Selected == false)
                        {
                            TrackerVariables.TrackedVariables.FullGrid[(_startX + _increase),
                                (_startY + _increase)].Selected = true;
                        }
                    }
                }
                else
                {
                    for (int _increase = 1;
                         _increase < _endX - _startX;
                         _increase++)
                    {
                        if (TrackerVariables.TrackedVariables.FullGrid[(_startX + _increase),
                            (_endY - _increase)].Selected == false)
                        {
                            TrackerVariables.TrackedVariables.FullGrid[(_startX + _increase),
                                (_endY - _increase)].Selected = true;
                        }
                    }
                }
            }
            // Remove the last clicked square from list and add again 
            // so it is the last clicked
            TrackerVariables.TrackedVariables.SelectedLetters.Remove(_secondClick);
            TrackerVariables.TrackedVariables.SelectedLetters.Add(_secondClick);

        }