Exemple #1
0
        public void SetItem(int row, int col, MazeStates value)
        {
            if (value == MazeStates.Finish || value == MazeStates.Start)
            {
                FindAndReplace(value, MazeStates.Empty);
            }

            maze[row, col] = value;
        }
Exemple #2
0
 private void FindAndReplace(MazeStates findValue, MazeStates replaceValue)
 {
     for (var i = 0; i < _rows; i++)
     {
         for (var j = 0; j < _cols; j++)
         {
             if (GetItem(i, j) == findValue)
             {
                 SetItem(i, j, replaceValue);
             }
         }
     }
 }
Exemple #3
0
 public bool ExistState(MazeStates findValue)
 {
     for (var i = 0; i < _rows; i++)
     {
         for (var j = 0; j < _cols; j++)
         {
             if (GetItem(i, j) == findValue)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #4
0
        public Point GetFirstItemByType(MazeStates findValue)
        {
            for (var i = 0; i < _rows; i++)
            {
                for (var j = 0; j < _cols; j++)
                {
                    if (GetItem(i, j) == findValue)
                    {
                        return(new Point(j, i));
                    }
                }
            }

            return(null);
        }