Ejemplo n.º 1
0
    void Update()
    {
        var maxZ        = CameraController.GetMaxZ();
        int currentTime = 0;

        if (startTimer)
        {
            // A timer for how long the player has been playing
            timer      += Time.deltaTime;
            currentTime = System.Convert.ToInt32(timer); // Only counts the seconds

            // Update the file of the state
            //File.AppendAllText(filePath, "\r\nCurrent Time: " + timer );
        }
        if (currentTime >= 300)
        {
            endGame(currentTime);
        }

        // Calculates the difficulty
        difficultySettings.setDifficultySettings(difficultyLvl);

        // As soon as 60 seconds pass, it will create the baseline of the current data collected.
        if (timer >= 60)
        {
            // Ensures it is only created once, when it passes the 60 second mark.
            if (createBaselineNow)
            {
                difficultyLvl = 2;
                //File.AppendAllText(filePath, " --> Increase difficulty to " + difficultyLvl);

                // Creates the baseline, and then never creates the baseline again.
                baseline.createBaseline(); createBaselineNow = false;
            }
        }

        // Spawn a new plane if we need to
        if (planeEdgeZ - maxZ <= offscreenSpawnOffset)
        {
            // Calls the methods to spawn the terrain
            SpawnNewPlane(offscreenSpawnOffset);

            // Depending on the difficulty, it will spawn x number of cars
            for (int i = 0; i <= numberOfCars; i++)
            {
                // The cars will spawn at x distance from the previously spawned car
                spawnCars(startDistance, startDistance);  startDistance += distance;
            }
        }
    }