-
Notifications
You must be signed in to change notification settings - Fork 0
/
chest.cs
59 lines (50 loc) · 1.07 KB
/
chest.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
using UnityEngine;
using System.Collections;
public class chest : MonoBehaviour {
private Animator anim;
private int randomNumber;
public GameObject[] loot;
public Transform lootSpawn;
public bool openChest;
public int lootSize;
// Use this for initialization
void Start ()
{
anim = GetComponent<Animator> ();
openChest = false;
}
// Update is called once per frame
void FixedUpdate ()
{
if(openChest == true)
{
anim.SetBool("Open",true);
}
}
void OnCollisionEnter2D(Collision2D bullet)
{
if(bullet.gameObject.tag == "bullet")
{
anim.SetBool("Open",true);
bullet bb = bullet.gameObject.GetComponent<bullet>();
bb.destroy = true;
}
if(bullet.gameObject.tag == "Bomb")
{
if(bullet.gameObject.name == "Grenade(Clone)")
{
Grenade gr = bullet.gameObject.GetComponent<Grenade>();
gr.explode = true;
}
}
}
//Metodo que Instancia
void lanzarGemas()
{
for(int i = 0; i < lootSize; i++)
{
randomNumber = Random.Range(0,7);
Instantiate(loot[randomNumber],transform.position,transform.rotation);
}
}
}