-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spawner.cs
63 lines (41 loc) · 1.3 KB
/
Spawner.cs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Collections;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject nagent;
public GameObject goalObject;
public GameObject carPolice;
public AudioClip SireneAudio;
void SpawnAgent()
{
GameObject na = (GameObject)Instantiate(nagent, this.transform.position, Quaternion.identity);
na.GetComponent<agentWalk>().goal = goalObject.transform;
}
void SpawnCar()
{
Instantiate(carPolice, transform.position, transform.rotation);
}
void PlaySiren()
{
AudioSource.PlayClipAtPoint(SireneAudio, transform.position);
}
void Update()
{
if (GameManager.Instance.SpawnEnemies && GameManager.Instance.NumberOfAgents < 5 && GameManager.Instance.NumberOfPolice == 0)
{
SpawnAgent();
SpawnAgent();
SpawnAgent();
SpawnAgent();
GameManager.Instance.NumberOfAgents++;
GameManager.Instance.NumberOfAgents++;
GameManager.Instance.NumberOfAgents++;
GameManager.Instance.NumberOfAgents++;
SpawnCar();
GameManager.Instance.NumberOfPolice++;
PlaySiren();
}
{
}
}
}