Ejemplo n.º 1
0
 public Cell this[CellPoint point]
 {
     get
     {
         if (point.Row < 0 || point.Row >= Rows || point.Column < 0 || point.Column >= Columns)
         {
             throw new IndexOutOfRangeException();
         }
         return(cells[point.Row][point.Column]);
     }
 }
Ejemplo n.º 2
0
        public static CellPoint RandomCellPoint(this Maze maze, Random random)
        {
            CellPoint point;

            do
            {
                int row = random.Next(0, maze.Rows);
                int col = random.Next(0, maze.Columns);
                point = new CellPoint(row, col);
                var points = maze.characters.Select(x => x.location.location).ToList();
                if (points.Contains(point))
                {
                    continue;
                }
            }while (false);
            return(point);
        }
        private Cell GetNextCell(CellPoint point, Direction dir)
        {
            switch (dir)
            {
            case Direction.Up:
                point.Row--;
                if (point.Row < 0)
                {
                    return(NotCell.GetInstance());
                }
                break;

            case Direction.Right:
                point.Column++;
                if (point.Column >= maze.Columns)
                {
                    return(NotCell.GetInstance());
                }
                break;

            case Direction.Down:
                point.Row++;
                if (point.Row >= maze.Rows)
                {
                    return(NotCell.GetInstance());
                }
                break;

            case Direction.Left:
                point.Column--;
                if (point.Column < 0)
                {
                    return(NotCell.GetInstance());
                }
                break;
            }
            return(maze[point]);
        }
Ejemplo n.º 4
0
 public MazeCell(int row, int col, int _id = 0)
 {
     location    = new CellPoint(row, col);
     Id          = _id;
     connections = new Cell[4];
 }