EndlessRunner.AddPlatforms C# (CSharp) Method

AddPlatforms() public method

public AddPlatforms ( ) : void
return void
    void AddPlatforms()
    {
        for(int i = totalPlatforms; i < totalPlatforms + numPlatforms-1; i++)
        {
            //we're going to select one randomly from this list. to increase the probability of one
            //type over another, include it more than once!
            string[] platforms = {"Platform", "Platform", "Platform", "Blocky", "Gap"};
            int which_platform = Random.Range(0, platforms.Length);
            GameObject obj = Instantiate(Resources.Load(platforms[which_platform])) as GameObject;
            obj.transform.Translate(Vector3.right * platformSpacingX*i);
            obj.transform.Translate(Vector3.up * Random.Range(-platformSpacingY, platformSpacingY));

        }

        goal = Instantiate(Resources.Load("Goal")) as GameObject;
        goal.transform.Translate(Vector3.right * platformSpacingX*(totalPlatforms + numPlatforms-1));

        totalPlatforms += numPlatforms;
    }