using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class BombScript : MonoBehaviour {

    public Transform blast;

    // Use this for initialization
    void Start () {

		
	}
	
	// Update is called once per frame
	void Update () {
	}

    void OnCollisionEnter2D(Collision2D collision)
    {
        // can't detonate on bombs or enemies
        if (collision.gameObject.GetComponent<BombScript>()) return;
        if (collision.gameObject.GetComponent<EnemyScript>()) return;

        // otherwise detonate
        PlayerPrefs.SetInt("NeedBoom",1);
        Vector3 p = this.transform.position;
        p.y -= 0.2f;
        Transform t = Instantiate(blast, p, Quaternion.identity);
        Vector3 scl = new Vector3(0.2f, 0.2f, 1);
        t.localScale = scl;
        Destroy(this.gameObject);
    }

}
