aboutsummaryrefslogtreecommitdiff
path: root/td/Assets/Scripts/EnemySpawner.cs
blob: eb0dd43f19bd307b32c1ff206572722ca88dc929 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
		}
	}
}