Ejemplo n.º 1
0
        private static bool TryAddComponent(GridSettings gridSettings, ref int components, Vector2Int next)
        {
            GridPoint nextPoint = gridSettings.grid[next.x, next.y];

            nextPoint.visits++;

            if (components >= gridSettings.maxComponents)
            {
                return(false);
            }

            if (components >= gridSettings.minComponents && Random.Range(0f, 1f) < gridSettings.componentStopChance)
            {
                return(true);
            }

            components++;
            nextPoint = new GridPoint(components, nextPoint.visits + 1);
            gridSettings.grid[next.x, next.y] = nextPoint;
            return(true);
        }
Ejemplo n.º 2
0
        private static bool TryAddGridPoint(GridSettings gridSettings, Vector2Int curr, Vector2Int next)
        {
            GridPoint currPoint = gridSettings.grid[curr.x, curr.y];
            GridPoint nextPoint = gridSettings.grid[next.x, next.y];

            nextPoint.visits++;

            if (currPoint.depth >= gridSettings.maxRange)
            {
                return(false);
            }

            if (currPoint.depth >= gridSettings.minRange && Random.Range(0f, 1f) < gridSettings.stepStopChance)
            {
                return(false);
            }

            nextPoint = new GridPoint(currPoint.value, nextPoint.visits + 1, currPoint);
            gridSettings.grid[next.x, next.y] = nextPoint;
            return(true);
        }