Пример #1
0
        /// <summary>
        /// Get all neighbours that havent been traversed
        /// </summary>
        private List <Vector2Int> GetNeighbours(int x, int y)
        {
            // get all neighbour cells
            List <Vector2Int> neighbours = maze.GetCellsAtEdge(new Vector2Int(x, y), wallSpacing, includeDiagonals);

            // remove all cells that have been traversed
            neighbours = neighbours.FindAll(n => maze[n] == 0);

            // apply mask (if there is one)
            if (mask != null)
            {
                List <Vector2Int> maskedNeighbours = new List <Vector2Int>();

                for (int i = neighbours.Count - 1; i >= 0; i--)
                {
                    if (mask.IsInsideBounds(neighbours[i]))
                    {
                        if (mask[neighbours[i]] > 0)
                        {
                            maskedNeighbours.Add(neighbours[i]);
                        }
                    }
                }

                return(maskedNeighbours);
            }
            else
            {
                return(neighbours);
            }
        }