Пример #1
0
 void Update()
 {
     if (spawnCount > 0)
     {
         spawnCount -= Time.deltaTime;
         if (spawnCount <= 0)
         {
             position = new Vector3(Random.Range(-20, 20), 1, Random.Range(-20, 20)); // Spawns the enemies at a random position
             random   = Random.Range(1, 4);
             if (random <= 2)                                                         // chooses a random enemy to spawn, currently bias towards zombies over shooters
             {
                 ZombieController newEnemy = Instantiate(enemy, position, Quaternion.identity) as ZombieController;
             }
             else
             {
                 ShooterControler newEnemy = Instantiate(shooter, position, Quaternion.identity) as ShooterControler;
             }
             spawnCount = spawnTime;
             if (spawnTime > 2) // These speed up the spawning to make the game harder
             {
                 spawnTime -= 0.2f;
             }
             else if (spawnTime > 1)
             {
                 spawnTime -= 0.1f;
             }
         }
     }
 }
Пример #2
0
    private void EnemyDelay()        // The enemy is spawned 1 second after the particle effect apears.
    {
        random = Random.Range(1, 6); // chooses a random enemy
        if (random <= 2)             // chooses the enemy to spawn
        {
            ZombieController newEnemy = Instantiate(zombie, transform.position, Quaternion.identity) as ZombieController;
        }
        else if (random == 3)
        {
            ShooterControler newEnemy = Instantiate(shooter, transform.position, Quaternion.identity) as ShooterControler;
        }
        else if (random == 4)
        {
            runnerController newEnemy = Instantiate(runner, transform.position, Quaternion.identity) as runnerController;
        }
        else if (random == 5)
        {
            shotgunnerController newEnemy = Instantiate(shotgunner, transform.position, Quaternion.identity) as shotgunnerController;
        }

        Destroy(gameObject); // deletes the particle effect
    }