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

public class GunPickable : Pickable
{
    private bool InHand;

    public override void Start()
    {
        base.Start();
        gameObject.GetComponent<Gun>().enabled = false;
    }

    public override void Interact()
    {
        base.Interact();
        gameObject.GetComponent<Gun>().enabled = true;
        gameObject.GetComponent<AudioSource>().PlayOneShot(GameManager.instance.handling);
        InHand = true;
    }

    public override void Drop()
    {
        base.Drop();
        gameObject.GetComponent<Gun>().enabled = false;
        GameObject.Find("bullet counter").GetComponent<TextMeshProUGUI>().text="";
        InHand = false;
    }

    public override void Update()
    {
        if (InHand)
        {
            Vector3 currentRotation = transform.eulerAngles;
            currentRotation.x = Camera.transform.eulerAngles.x;
            transform.eulerAngles = currentRotation;
        }
        base.Update();
    }
    
}
