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

public class Shooting_Rockets : MonoBehaviour
{
    [SerializeField] private KeyCode shootingKeyCode = KeyCode.Mouse1;
    public GameObject Rockets_Prefab;
    public bool isUnlocked = false;  // Bool wird durch den Shop geƤndert
    [SerializeField] private float shootDelay = 1;
    private float timer = 0;

    void Update()
    {
        HandleShootingRockets();
    }

    private void HandleShootingRockets()
    {
        if (!isUnlocked) return;

        timer += Time.deltaTime;

        if (Input.GetKeyDown(shootingKeyCode) && timer >= shootDelay)
        {

            timer = 0;

            if (Rockets_Prefab != null)
            {
                GameObject newBullet = Instantiate(Rockets_Prefab, transform.position, Quaternion.identity);
                newBullet.transform.up = transform.up;
            }
        }
    }

    public void UnlockWeapon()
    {
        isUnlocked = true;
        Debug.Log("Raketenwerfer wurde freigeschaltet!");
    }
}