//Oliver
using Unity.VisualScripting;
using UnityEngine;
public class Shoot : MonoBehaviour
{
    [SerializeField] GameObject bulletPrefab;
    [SerializeField] Transform spawnPointAR;
    [SerializeField] Transform spawnPointPistol;
    [SerializeField] bool AR = true;
    [SerializeField] bool Pistole = true;
    void Start()
    {
<<<<<<< HEAD
<<<<<<< HEAD
        
=======
        if (weapon == null)
            weapon = FindFirstObjectByType<WeaponReload>();
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
        if (weapon == null)
            weapon = FindFirstObjectByType<WeaponReload>();
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
    }

    void Update()
    {
<<<<<<< HEAD
<<<<<<< HEAD
        
        if ( AR == true && Input.GetKey(KeyCode.Mouse0))
=======
        if (PauseMenu.GameIsPaused) return;
        
        if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
        if (PauseMenu.GameIsPaused) return;
        
        if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
        {
            Shot(spawnPointAR);
        }
        else if (Pistole == true && Input.GetKeyDown(KeyCode.Mouse0))
        {
            Shot(spawnPointPistol);
        }
    }
    public void Shot(Transform spawnPoint)
    {
        GameObject bullet = Instantiate(bulletPrefab, spawnPoint.position, spawnPoint.rotation);
        bullet.transform.Rotate(90,0,0);
        Destroy(bullet, 2);
    }
}
