Exemplo n.º 1
0
    private void buildRandomLine(LevelObject l)
    {
        int rand         = Random.Range(0, 2);
        int randlength   = Random.Range(0, 8);
        int randobstacle = Random.Range(1, 3);

        for (int i = 0; i < randlength / randobstacle; i++)
        {
            switch (rand)
            {
            case 0:
                l.AddBottomBlockLine(randobstacle);
                break;

            case 1:
                l.AddMiddleBlockLine(randobstacle);
                break;

            case 2:
                l.AddTopBlockLine(randobstacle);
                break;
            }
            if (Random.Range(0, 15) > 10)
            {
                l.AddFloorBlockToLast(randobstacle);
            }
            l.AddRandomToLast();
        }
    }
Exemplo n.º 2
0
    public LevelObject BuildRandomLevel(int length, int delay = 0, int difficulty = 0)
    {
        LevelObject l = new LevelObject();

        l.SetDelay(delay);
        for (int i = 0; i < length; i++)
        {
            int rand = Random.Range(0, 50);
            if (rand + difficulty < 8)
            {
                PickRandomSimpleBlock(l);
            }
            else if (rand < 40)
            {
                PickRandomComplexBlock(l);
            }
            else if (rand < 48)
            {
                l.SetDelay(0);
                buildRandomLine(l);
                l.SetDelay(delay);
            }
            else
            {
                l.AddFloorBlockToLast(0.6f);
            }
        }
        return(l);
    }