Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Platformer/Platformer/Assets/Scripts/Player&Enemy/Spawner1.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (51 sloc)
1.61 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Spawner1 : MonoBehaviour | |
{ | |
//spawner from spaceshooter | |
public GameObject hazard; | |
public int hazardCount; | |
public float spawnWait; | |
public float startWait; | |
public float waveWait; | |
public Transform spawnhere; | |
//start the courotine right away | |
void Start() | |
{ | |
StartCoroutine(SpawnWaves()); | |
} | |
//start spawning | |
IEnumerator SpawnWaves() | |
{ | |
yield return new WaitForSeconds(startWait); | |
while (true) | |
{ | |
//setup to handle multiple enemies | |
for (int i = 0; i < hazardCount; i++) | |
{ | |
//First Enemy | |
if( i == 0) | |
{ | |
Quaternion spawnRotation = Quaternion.identity; | |
yield return new WaitForSeconds(spawnWait); | |
Instantiate(hazard, spawnhere.position, spawnRotation); | |
} | |
//Second Enemy | |
if (i == 1) | |
{ | |
Quaternion spawnRotation = Quaternion.identity; | |
Instantiate(hazard, spawnhere.position, spawnRotation); | |
yield return new WaitForSeconds(spawnWait); | |
} | |
if (i == 2) | |
{ | |
Quaternion spawnRotation = Quaternion.identity; | |
Instantiate(hazard, spawnhere.position, spawnRotation); | |
yield return new WaitForSeconds(spawnWait); | |
} | |
} | |
yield return new WaitForSeconds(waveWait); | |
} | |
} | |
} |