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

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

    void Update()
    {
        HandleShootingPlasma();
    }

    private void HandleShootingPlasma()
    {
        if (!isUnlocked) return;
        
        timer += Time.deltaTime;
        if (Input.GetKey(shootingKeyCode) && timer >= shootDelay)
        {

            timer = 0;

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

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