Advertisement
Guest User

enemy waves

a guest
Jun 2nd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1.     public Transform[] spawn_spots;
  2.     public GameObject enemy;
  3.     public float GameTime, seconds;
  4.     public bool wave_1, wave_2, wave_3 = false;
  5.  
  6.     void Update()
  7.     {
  8.         seconds = (int)(GameTime % 60f);
  9.         GameTime += Time.deltaTime;
  10.  
  11.         if (seconds == 5)
  12.         {
  13.             wave_1 = true;
  14.             if (wave_1)
  15.             {
  16.                 InvokeRepeating("Spawn", 3.0f, 3.0f);
  17.             }
  18.         }
  19.  
  20.         if (seconds == 10)
  21.         {
  22.             wave_2 = true;
  23.             wave_1 = false;
  24.             if (wave_2)
  25.             {
  26.                 InvokeRepeating("Spawn_2", 5.0f, 5.0f);
  27.             }
  28.         }
  29.     }
  30.  
  31.     void Spawn()
  32.     {
  33.         int spawnPointIndex = Random.Range(0, spawn_spots.Length);
  34.         Instantiate(enemy, spawn_spots[spawnPointIndex].position, spawn_spots[spawnPointIndex].rotation);
  35.     }
  36.  
  37.     void Spawn_2()
  38.     {
  39.         int spawnPointIndex = Random.Range(0, spawn_spots.Length);
  40.         Instantiate(enemy, spawn_spots[spawnPointIndex].position, spawn_spots[spawnPointIndex].rotation);
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement