예제 #1
0
    void CreateForegroundElements()
    {
        float x = 0f;

        while (x <= worldWidth)
        {
            if (UnityEngine.Random.value <= chanceToSpawnForegroundElement)
            {
                float x_pos = x + UnityEngine.Random.Range(foreground_HorizontalDistribution.x, foreground_HorizontalDistribution.y);

                if (x_pos > worldWidth)
                {
                    x = worldWidth + 1f;
                    break;
                }

                GenericTrash foreground = GetNewForegroundElement();

                x = GetNextXPositionFor(foreground, x_pos);

                x_pos += tleft.position.x;

                Vector2 pos = new Vector2(x_pos, tdown.position.y + foreground.GetHeight() * 0.5f);

                foreground.CachedTransform.position = pos;
            }
            else
            {
                x += UnityEngine.Random.Range(background_HorizontalDistribution.x, background_HorizontalDistribution.y);
            }
        }
    }
예제 #2
0
    void CreateWorldSegments()
    {
        float x = world_PaddingRange.y;

        float padding = world_PaddingRange.y;

        while (x <= worldWidth - padding)
        {
            GenericTrash worldSegment = GetNewWorldSegment();

            //worldSegment.CachedTransform.parent = CachedTransform;

            float x_pos = GetXPositionFor(worldSegment, x);

            x = GetNextXPositionFor(worldSegment, x_pos) + GetPadding();

            x_pos += tleft.position.x;

            float y = tdown.position.y + worldSegment.GetHeight() * 0.5f;

            Vector2 pos = new Vector2(x_pos, y);

            worldSegment.CachedTransform.position = pos;
        }
    }
예제 #3
0
    void CreateSky()
    {
        float y = 0f;

        while (y <= worldHeight)
        {
            float x        = 0f;
            float y_height = 0f;

            while (x <= worldWidth)
            {
                GenericTrash sky = GetNewSky();

                y_height = sky.GetHeight();

                float x_pos = GetXPositionFor(sky, x);

                x = GetNextXPositionFor(sky, x_pos);

                x_pos += tleft.position.x;

                Vector2 pos = new Vector2(x_pos, y + tdown.position.y);

                sky.CachedTransform.position = pos;
            }

            y += y_height;
        }
    }