Ejemplo n.º 1
0
    void SetObstacleLine(float levelOffset)
    {
        foreach (float lanePosn in renderConfig.lanePosns)
        {
            if (curPosn_LC > gameState.nextGasLocation)
            {
                o = gasPool.Next();
                UpdateGasLocation();
                DynamicRoadObject.ResetObject(o);
                o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
                continue;
            }

            if (Random.value < difficulty.obstacleSpawnProbability)
            {
                o = obstaclePool.Next();
                DynamicRoadObject.ResetObject(o);
                o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
                continue;
            }

            if (Random.value < difficulty.coinSpawnProbability)
            {
                o = coinPool.Next();
                DynamicRoadObject.ResetObject(o);
                o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
                continue;
            }
        }
    }
Ejemplo n.º 2
0
    protected void SetObstacleLine(float levelOffset)
    {
        for (int i = 0; i < renderConfig.lanePosns.Length; i++)
        {
            float lanePosn = renderConfig.lanePosns[i];

            if (i == gapIdx)
            {
                if (curPosn_LC > gameState.nextGasLocation)
                {
                    o = gasPool.Next();
                    UpdateGasLocation();
                    DynamicRoadObject.ResetObject(o);
                    o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
                    continue;
                }

                o = coinPool.Next();
                DynamicRoadObject.ResetObject(o);
                o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
                continue;
            }

            o = obstaclePool.Next();
            DynamicRoadObject.ResetObject(o);
            o.transform.position = new Vector3(curPosn_LC + levelOffset, 0f, lanePosn);
        }

        if (gapIdx == 0)
        {
            gapIdx += 1;
            //gapIdx += Random.Range(0, 2);
            return;
        }

        if (gapIdx == renderConfig.lanePosns.Length - 1)
        {
            gapIdx -= 1;
            //gapIdx -= Random.Range(0, 2);
            return;
        }

        gapIdx += Random.Range(0, 2) * 2 - 1;
        //gapIdx += Random.Range(0, 3) - 1;
    }