diff options
author | Jakob Stendahl <jakst070500@ntvgs.no> | 2017-09-29 12:42:11 +0200 |
---|---|---|
committer | Jakob Stendahl <jakst070500@ntvgs.no> | 2017-09-29 12:42:11 +0200 |
commit | 76cf99ade6530bdad81088295fb4cf73f5c5b118 (patch) | |
tree | e3cf549687d164c11d6b292d771534e98bcc97a8 /td/Assets/Scripts/EnemySpawner.cs | |
parent | 608b6a0e692a580f0dfabef0b2ef1a59f0a37234 (diff) | |
parent | 9a00d03f80eee94c9fe52f832a0127d9375ad375 (diff) | |
download | TD-76cf99ade6530bdad81088295fb4cf73f5c5b118.tar.gz TD-76cf99ade6530bdad81088295fb4cf73f5c5b118.zip |
Merge branch 'master' of https://github.com/JakobS1n/unityTest
Diffstat (limited to 'td/Assets/Scripts/EnemySpawner.cs')
-rw-r--r-- | td/Assets/Scripts/EnemySpawner.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/td/Assets/Scripts/EnemySpawner.cs b/td/Assets/Scripts/EnemySpawner.cs new file mode 100644 index 0000000..eb0dd43 --- /dev/null +++ b/td/Assets/Scripts/EnemySpawner.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EnemySpawner : MonoBehaviour { + + public Enemy enemyPrefab; + public Transform pathWay; + public Transform gameWorld; + + int wave; + int next = 1; + int n = 0; + + void Update () { + n++; + + if (n == next) { + n = 0; + next = (int)Random.Range (50, 400); + + Enemy newEnemy = Instantiate (enemyPrefab, new Vector3(0, 0, 0), Quaternion.identity, gameWorld); + newEnemy.GetComponent <Enemy> ().pathWay = pathWay; + newEnemy.GetComponent <Enemy> ().speed = Random.Range (0.3f, 1.2f); + } + } +} |