Exemplo n.º 1
0
    void Update()
    {
        if (transform.position.y > generationPoint.position.y)
        {
            Platform next = generator.Next();

            transform.position = new Vector3(
                transform.position.x,
                transform.position.y - (distanceBetweenPlatforms + platformHeight),
                transform.position.z);

            float      x1       = 0.0f;
            float      width1   = next.FirstGap.Position - next.FirstGap.Width / 2;
            GameObject platform = CreatePlatform(x1, width1);

            CreateTrigger(next.FirstGap.Position, next.FirstGap.Width, next.FirstGap.City, platform);

            float x2     = next.FirstGap.Position + next.FirstGap.Width / 2;
            float width2 = (next.SecondGap.Position - next.SecondGap.Width / 2) - x2;
            CreatePlatform(x2, width2);

            CreateTrigger(next.SecondGap.Position, next.SecondGap.Width, next.SecondGap.City, platform);

            float x3     = next.SecondGap.Position + next.SecondGap.Width / 2;
            float width3 = 1.0f - x3;
            CreatePlatform(x3, width3);
        }
    }