LevelController.addNextSection C# (CSharp) Method

addNextSection() private method

private addNextSection ( ) : void
return void
    private void addNextSection()
    {
        GameObject nextSection = GetSectionForDifficulty(CalculateDifficulty(currentLength));
        GameObject lastSection = ((GameObject) currentPath [currentPath.Count-1]);
        Vector3 pos = lastSection.transform.position;
        pos.z += lastSection.GetComponent<SectionController>().Length/2;
        GameObject newObject = (GameObject) Instantiate(nextSection, pos, Quaternion.identity);
        float newObjectLength = newObject.GetComponent<SectionController>().Length;
        pos.z += newObjectLength/2;
        newObject.transform.position = pos;
        currentLength += newObjectLength;
        currentPath.Add(newObject);
    }