-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombatCollision.cs
More file actions
57 lines (42 loc) · 1.23 KB
/
CombatCollision.cs
File metadata and controls
57 lines (42 loc) · 1.23 KB
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
using UnityEngine;
using System.Collections;
public class CombatCollision : MonoBehaviour {
public GameObject[] Spawner;
GameObject[] combatSpawn;
public int randomNum = 0, i = 0;
private bool spawnChnager = true, waitDelay = false;
// Use this for initialization
void Start () {
if(combatSpawn == null)
combatSpawn = GameObject.FindGameObjectsWithTag("combattrigger");
foreach (GameObject spawn in combatSpawn)
{
Spawner[i] = spawn;
i++;
}
for (int i = 0; i < 42; i++)
{
Spawner[i].SetActive(false);
}
StartCoroutine(TimeDelay(3));
}
// Update is called once per frame
void Update()
{
randomNum = Random.Range(0, 100);
if (Spawner[i] == null && waitDelay == false)
i = 0;
else if(randomNum <= 65 && waitDelay == false)
Spawner[i].SetActive(spawnChnager);
else if(waitDelay == false)
Spawner[i].SetActive(false);
if(waitDelay == false)
i++;
}
IEnumerator TimeDelay(float timedelay)
{
waitDelay = true;
yield return new WaitForSeconds(timedelay);
waitDelay = false;
}
}