Exemplo n.º 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;
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ObstacleGenerator generator = (ObstacleGenerator)target;

        string[] names = new string[generator.obstacles.Length];
        for (int i = 0; i < generator.obstacles.Length; ++i)
        {
            names[i] = generator.obstacles[i].name;
        }

        next_obstacle = EditorGUILayout.Popup("Next obstacle", next_obstacle, names);
        if (GUILayout.Button("Generate Next"))
        {
            generator.AddObstacle(next_obstacle);
        }
    }