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

public class dim : MonoBehaviour {

    Light lightComp;
    // Use this for initialization
    void Start () {
        lightComp = GetComponent<Light>();
    }
	
	// Update is called once per frame
	void Update () {

        lightComp.intensity = Mathf.Lerp(lightComp.intensity, 0, 3.0f*Time.deltaTime);

        if(lightComp.intensity <= 0.01f)
        {
            var gun = GameObject.Find("Gun");

            if (transform.parent != null)
            {
                gun.SendMessage("ShootAgain");
                Destroy(transform.parent.gameObject);
            }
            else
                Destroy(gameObject);
        }
	}

}
