Exemple #1
0
    private void SpreadEnvironmentalZone(ZoneGeneration generationData, EnvironmentCube source)
    {
        int numSpread   = Random.Range(generationData.minSpread, generationData.maxSpread + 1);
        int spreadCount = 0;

        while (spreadCount < numSpread)
        {
            EnvironmentCube randomCube = GetRandomAdjacentCube(source, true);

            if (randomCube.cubeType != EnvironmentCube.CubeType.Water)
            {
                if (generationData.isCubeGeneration)
                {
                    source = ReplaceCube(randomCube, generationData.currentPrefab);
                }
                else
                {
                    randomCube.CreateEnvironmentalObject(generationData.currentPrefab);
                    source = randomCube;
                }

                spreadCount++;
            }
            else
            {
                source = randomCube;
            }
        }
    }
Exemple #2
0
    private void GenerateEnvironmentalZone(ZoneGeneration generationData)
    {
        int numSources = Random.Range(generationData.minSources, generationData.maxSources + 1);

        for (int i = 0; i < numSources; i++)
        {
            EnvironmentCube randomCube = GetRandomCubeOfType(EnvironmentCube.CubeType.Grass, true);
            EnvironmentCube sourceCube = randomCube;

            generationData.currentPrefab = generationData.prefabs[Random.Range(0, generationData.prefabs.Length)];

            if (generationData.isCubeGeneration)
            {
                sourceCube = ReplaceCube(randomCube, generationData.currentPrefab);
            }
            else
            {
                randomCube.CreateEnvironmentalObject(generationData.currentPrefab);
            }

            SpreadEnvironmentalZone(generationData, sourceCube);
        }
    }