예제 #1
0
    void GenerateTerrain()
    {
        RestartGame();
        terrainSize    = PrefabController.GetSize(PrefabController.Prefab.Terrain);
        halfRegionSize = terrainSize * 0.5f;
        TerrainGeneration terrain = PrefabController.CreateGameObject(PrefabController.Prefab.Terrain).GetComponent <TerrainGeneration>();

        terrain.Initialize(halfRegionSize);
        terrains.Add(TerrainPosition.Bot, terrain);
        float z             = terrains[TerrainPosition.Bot].Position.z + terrainSize.y;
        int   extraTerrains = (int)TerrainPosition.Count;

        for (int i = 1; i < extraTerrains; i++)
        {
            GameObject terrainClone = PrefabController.CreateGameObject(PrefabController.Prefab.Terrain);
            Vector3    position     = terrainClone.transform.position;
            position.z = z;
            terrainClone.transform.position = position;
            terrain = terrainClone.GetComponent <TerrainGeneration>();
            terrain.Initialize(halfRegionSize);
            terrains.Add((TerrainPosition)i, terrain);
            z += terrainSize.y;
        }
    }