Example #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);
            }
        }
Example #2
0
        /// <summary>
        /// Subtracts two Value Maps
        /// </summary>
        public ValueMap Subtract(ValueMap map)
        {
            var output = Clone();

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (map.IsInsideBounds(x, y))
                    {
                        output.values[x, y] = values[x, y] - map.values[x, y];
                    }
                }
            }

            return(output);
        }
Example #3
0
        /// <summary>
        /// Multiplies two Value Maps
        /// </summary>
        public ValueMap Multiply(ValueMap map)
        {
            ValueMap output = Clone();

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (map.IsInsideBounds(x, y))
                    {
                        output.values[x, y] = values[x, y] * map.values[x, y];
                    }
                }
            }

            return(output);
        }
Example #4
0
        /// <summary>
        /// Uses another ValueMap to mask this one, values less then or equal to zero are treated as masked
        /// </summary>
        public ValueMap ApplyMask(ValueMap mask, float threshold)
        {
            ValueMap output = Clone();

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (mask.IsInsideBounds(x, y))
                    {
                        if (mask[x, y] <= threshold)
                        {
                            output[x, y] = 0;
                        }
                    }
                }
            }

            return(output);
        }