LevelController.GetSectionForDifficulty C# (CSharp) Method

GetSectionForDifficulty() private method

private GetSectionForDifficulty ( float difficulty ) : GameObject
difficulty float
return GameObject
    private GameObject GetSectionForDifficulty(float difficulty)
    {
        bool spawnDynamic = Random.Range (0, 3) < sectionsSinceDynamic;
        if (spawnDynamic) {
            List<float> keys = new List<float> (dynamicSections.Keys);
            int i = keys.BinarySearch (difficulty);
            if (i < 0)
                i = ~i - 1;
            if (i == -1)
                i = 0;
            sectionsSinceDynamic = 0;
            return dynamicSections.Values [i];
        } else {
            sectionsSinceDynamic++;
            return staticSections[Mathf.RoundToInt(Random.Range(0f, (float) staticSections.Count()-1))];
        }
    }