-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebrisDestroy.cs
48 lines (41 loc) · 1001 Bytes
/
DebrisDestroy.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
using UnityEngine;
using System.Collections;
public class DebrisDestroy : MonoBehaviour {
public GameObject [] powerUp;
public bool destroy;
public int lootSize;
private float timer;
private int randomNumber;
// Use this for initialization
void Start ()
{
//timer = 0f;
destroy = false;
}
void FixedUpdate()
{
if(destroy == true)
{
for(int i = 0; i < lootSize; i++)
{
randomNumber = Random.Range(0,7);
Instantiate(powerUp[randomNumber],transform.position,transform.rotation);
}
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D cosa)
{
//Instancia 5 PowerUps y los lanza en direcciones random.
if (cosa.gameObject.tag == "bullet")
{
for(int i = 0; i < lootSize; i++)
{
randomNumber = Random.Range(0,7);
Instantiate(powerUp[randomNumber],transform.position,transform.rotation);
}
Destroy(gameObject);
Destroy(cosa.gameObject);
}
}
}