Ejemplo n.º 1
0
    private void SpawnBlocksInFrontOfPlayer(Vector3 startPos)
    {
        var pos = startPos;

        while (pos.z < _player.Position.z + _settings.fartherFromPlayerForward)
        {
            var block = _blockPool.Spawn(pos);
            Obstacle.ObstacleType prevObstacle;
            for (int i = 0, streak; i < 3; i++)
            {
                TryGetLaneLastObstacles(i, out prevObstacle, out streak);

                block[i].Obstacle =
                    _obstacleManager.ChooseAndGetObstacle(prevObstacle, streak, block[i].laneTransform);
            }
            _activeBlocks.Add(block);
            pos += Vector3.forward * _settings.blockDepth;
        }
    }