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

public class WeaponPickUpScript : MonoBehaviour {

    public int id;
    public bool used = false;
    public int magCount;
    public Light myLight;

	// Use this for initialization
	void Start () {
        myLight = GetComponentInChildren<Light>();
        myLight.intensity = 0;
	}
	
	// Update is called once per frame
	void Update () {
		// Rotate the object around its local X axis at 1 degree per second
		transform.Rotate(new Vector3 (0, 15, 0) * Time.deltaTime * 2);		
	}

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            if (id == 5)
                Destroy(gameObject);
			if (id == 4)
				if (other.gameObject.GetComponent<Player>().weapons[other.gameObject.GetComponent<Player>().currentWeapon] != 0)
					Destroy(gameObject);
            myLight.intensity = 8;
        }
    }

    private void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                Destroy(gameObject);
            }
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            myLight.intensity = 0;
        }
    }
}
