Exemplo n.º 1
0
    void SpawnRandomObstacle()
    {
        int   rand             = Random.Range(0, 11);
        float timeSinceStarted = Time.time - TimeElapsed.initialTime;

        if (rand == 1 || rand == 5 || rand == 8)
        {
            StartCoroutine(spawnCircle(Random.Range(4f, 8f)));
        }
        else if (rand == 2 && (timeSinceStarted > 60 || GameManager.score > 7000))
        {
            Debug.Log("spawned double vertical wall at time: " + timeSinceStarted + " and score: " + GameManager.score);
            spawnDoubleVerticalWall(0.7f);
            obstacleSpawnDelay += 2f;
            enemySpawnDelay    += 0.5f;
            spawnExplosive();
        }
        else if (rand == 7 && (timeSinceStarted > 60 || GameManager.score > 7000))
        {
            Debug.Log("spawned double horizontal wall at time: " + timeSinceStarted + " and score: " + GameManager.score);
            spawnDoubleHorizontalWall(0.7f);
            obstacleSpawnDelay += 2f;
            enemySpawnDelay    += 0.5f;
            spawnExplosive();
        }
        else if (rand == 6 && (timeSinceStarted > 90 || GameManager.score > 10000))
        {
            Debug.Log("spawned 4 walls at time: " + timeSinceStarted + " and score: " + GameManager.score);
            spawnDoubleVerticalWall(0.5f);
            spawnDoubleHorizontalWall(0.5f);
            obstacleSpawnDelay += 5f;
            enemySpawnDelay    += 1f;
            spawnShield();
        }
        else if (rand == 3 && (timeSinceStarted > 45 || GameManager.score > 3000))
        {
            spawnVerticalWall(Random.Range(0, 2) == 0 ? "right" : "left", 1.5f, (DifficultyManager.difficulty == 2) ? 1.5f : 1f);
        }
        else if (rand == 4 && (timeSinceStarted > 45 || GameManager.score > 3000))
        {
            spawnHorizontalWall(Random.Range(0, 2) == 0 ? "up" : "down", (DifficultyManager.difficulty == 2) ? 1.5f : 1f);
        }
        else
        {
            instantSpawnEnemies(SpawnHelpers.GetRangeForInstantSpawn());
        }
    }