Пример #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;
        }
Пример #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);
             }
         }
     }
 }
Пример #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);
 }
Пример #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);
        }