예제 #1
0
    public void GenerateObstacles(int genDistance)
    {
        for (int h = 0; h < height.Length; h++)
        {
            int parts         = 0;
            int distanceParts = genDistance / Mathf.FloorToInt(spacing);

            while (parts < distanceParts)
            {
                int rand = Random.Range(0, generator.obstacles.Count);

                if (generator.obstacles[rand].heights[h])
                {
                    if (Random.Range(0, 100) < generator.obstacles[rand].chances)
                    {
                        float position = parts * spacing + Random.Range(0, spacing - 20.0f) + 20.0f;
                        generator.SpawnObstacle(generator.obstacles[rand].tag, new Vector3(-2.0f, height[h], position + readyDistance)).SetActive(true);
                        parts++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
        readyDistance += genDistance;
    }