Added patron spawner.
This commit is contained in:
parent
5aac6aa72a
commit
c0ee8ea5c3
5 changed files with 61 additions and 14 deletions
|
|
@ -6,13 +6,21 @@ public class GameController : MonoBehaviour {
|
|||
public int swigs;
|
||||
public GUIText swigText;
|
||||
public GUIText scoreText;
|
||||
public int patronCount;
|
||||
public float spawnWait;
|
||||
public float startWait;
|
||||
public float waveWait;
|
||||
public GameObject[] patron;
|
||||
|
||||
private int score = 0;
|
||||
private int patrons = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
UpdateSwigText ();
|
||||
UpdateScoreText ();
|
||||
|
||||
StartCoroutine (SpawnWaves ());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
@ -20,6 +28,28 @@ public class GameController : MonoBehaviour {
|
|||
|
||||
}
|
||||
|
||||
IEnumerator SpawnWaves ()
|
||||
{
|
||||
yield return new WaitForSeconds (startWait);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (patrons < patronCount)
|
||||
{
|
||||
Vector3 spawnPosition = new Vector3 (40f, 2.5f, 10f);
|
||||
Quaternion spawnRotation = Quaternion.identity;
|
||||
|
||||
GameObject patron = Instantiate (patron[Random.Range (0, patron.Length)], spawnPosition, spawnRotation);
|
||||
|
||||
patrons++;
|
||||
|
||||
yield return new WaitForSeconds (spawnWait);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds (waveWait);
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeSwig() {
|
||||
swigs -= 1;
|
||||
UpdateSwigText();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue