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

public class BulletScript : MonoBehaviour {	
	
    public GameObject Spark;
    public Transform SparkPoint;

	void Update ()
    {
        
        
	}

    private void OnCollisionEnter2D(Collision2D collision)
    {
        
        if (collision.gameObject.GetComponent<ScientistScript>() == true)
            collision.gameObject.GetComponent<ScientistScript>().Die();
        if (collision.gameObject.GetComponent<SoldierShoot>() == true)
            collision.gameObject.GetComponent<SoldierShoot>().Die();
        if (collision.gameObject.GetComponent<GhostbusterScript>() == true)
            collision.gameObject.GetComponent<GhostbusterScript>().Die();

        if (collision.transform.tag != "Possessed") {
            
            GameObject TempSpark =  GameObject.Instantiate(Spark,SparkPoint.position , this.gameObject.transform.rotation);
            
            if (this.transform.localScale.x == 1)
                TempSpark.transform.localScale = this.gameObject.transform.localScale- new Vector3(2,0,0);
                
            Destroy(this.gameObject);
        
        }

    }

     private void OnTriggerEnter2D(Collider2D collision) {

         print(collision);
        
        if (collision.gameObject.GetComponent<ScientistScript>() == true) {

            collision.gameObject.GetComponent<ScientistScript>().Die();
            GameObject TempSpark =  GameObject.Instantiate(Spark,SparkPoint.position , this.gameObject.transform.rotation);
            
            if (this.transform.localScale.x == 1)
                TempSpark.transform.localScale = this.gameObject.transform.localScale- new Vector3(2,0,0);
                
            Destroy(this.gameObject);


        }
     

    }

    
}
