예제 #1
0
    private void AcquireLevelStatistics()
    {
        crystalPos        = ggm.GetCrystalLocations();
        initialDelay      = ggm.GetInitialDelay();
        levelLength       = ggm.GetLevelLength();
        renderDistance    = ggm.GetRenderDistance();
        terrainPrefabs    = ggm.GetTerrainPrefabs();
        terrainSpawnOrder = ggm.GetTerrainSpawnOrder();
        // Handling the appropriate seed.
        seed = ggm.GetSeed();
        if (seed == string.Empty)
        {
            seed = "StandardSeed";
        }
        if (ggm.GetRandomSeed())
        {
            seed = DateTime.Now.Ticks.ToString();
        }
        pseudoRandom = new System.Random(seed.GetHashCode());
        float totalTerrainLength = 0;

        if (terrainSpawnOrder.Count >= 1)
        {
            if (terrainPrefabs.Count > 0)
            {
                for (int i = 0; i < terrainSpawnOrder.Count; i++)
                {
                    // see what the length is between child 0 and 1 for the level and add it up.
                    totalTerrainLength += Mathf.Abs(terrainPrefabs[terrainSpawnOrder[i]].transform.GetChild(0).transform.position.x -
                                                    terrainPrefabs[terrainSpawnOrder[i]].transform.GetChild(1).transform.position.x);
                }
                // It's +45 because we begin populating from the LocatorRear which is at -30, and we want ~15m past the finishline
                PopulateTerrainSpawnOrder(totalTerrainLength);
            }
            else
            {
                Debug.Log("Terrain Prefab pool doesn't have anything in it");
            }
        }
        else
        {
            PopulateTerrainSpawnOrder(totalTerrainLength);
        }

        // placing the LevelBoundary Deactivator so it shuts off when it's supposed to.
        levelBoundaryRear.transform.GetChild(2).transform.position = new Vector3(-19 +
                                                                                 terrainPrefabs[terrainSpawnOrder[0]].transform.GetChild(1).transform.position.x, 0, 0);
    }