Modification start date
[BattleCats.git] / Assets / Scripts / BossScripts / GrenadeExplosion.cs
blob51eabd5c8fc3f12f5ce915fdd418dbf67dc56229
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
5 public class GrenadeExplosion : MonoBehaviour {
7 public float radius;
8 public int explosiveDelay;
10 public Transform explosion;
13 // Use this for initialization
14 void Start () {
15 radius = 5.0f;
16 explosiveDelay = 5;
17 StartCoroutine (Explode ());
20 // Update is called once per frame
21 void Update () {
25 IEnumerator Explode(){
26 yield return new WaitForSeconds (explosiveDelay);
27 Instantiate (explosion, transform.position, transform.rotation);
28 Destroy (gameObject);
31 private void OnCollisionEnter2D(Collision2D col)
33 if (col.gameObject.tag == "YarnPhysics")
35 col.gameObject.GetComponent<HealthSlider>().BulletDamage(this.tag, this.transform.position, this.gameObject);
36 Instantiate(explosion, transform.position, transform.rotation);
37 StopAllCoroutines();
38 Destroy(this.gameObject);
40 else if (col.gameObject.tag == "YarnABullet" || col.gameObject.tag == "YarnBBullet" || col.gameObject.tag == "YarnCBullet")
42 Instantiate(explosion, transform.position, transform.rotation);
43 StopAllCoroutines();
44 Destroy(this.gameObject);
45 Destroy(col.gameObject);