コード例 #1
0
    // create some obstacles before the game starts so that its not boring
    protected void CreateStartingObstacles()
    {
        // if already run, return without doing anything
        if (obstaclesPregenerated)
        {
            return;
        }
        float gameStartRotation = 180f;
        float rotationCounter   = 0f;

        // go until the wheel has arrived at the correct starting location for the game
        while (rotationCounter < gameStartRotation)
        {
            // modify obstacle spawn interval by rotation
            generator.IncreaseDifficultyOverTime();
            // spawn distance is the time interval for spawn in seconds times the wheel speed in degrees / second
            float spawnDist = generator.ObstacleSpawnInterval * wheel.RotationSpeed * 360.0f;
            // rotate one obstacle spawn distance
            wheel.ManualRotate(spawnDist);
            // increment counter
            rotationCounter += spawnDist;
            // create obstacle the normal way
            generator.AddObstacle();
            // distance rotated updates itself
        }
        // on complete
        obstaclesPregenerated = true;
    }