using UnityEngine; public class BlockDrop_PlayerShooter3D : MonoBehaviour { [Header("References")] public Transform muzzle; public GameObject bulletPrefab; public GameObject berryBombPrefab; [Header("Shooting Settings")] public float fireRate = 0.25f; [Header("Ammo")] public int maxBerryAmmo = 3; public float berryRegenCooldown = 8f; private float nextFire; private float berryRegenTimer; void Update() { // Regenerate berry ammo over time if (BlockDrop_GameManager3D.Instance.CurrentBerryAmmo < maxBerryAmmo) { berryRegenTimer -= Time.deltaTime; if (berryRegenTimer <= 0f) { BlockDrop_GameManager3D.Instance.AddBerryAmmo(1); berryRegenTimer = berryRegenCooldown; } } } // 🔫 UI button for shooting normal bullets public void OnShootBullet() { if (Time.time >= nextFire) { Shoot(bulletPrefab); nextFire = Time.time + fireRate; } } // 💣 UI button for shooting berry bombs public void OnShootBerryBomb() { if (BlockDrop_GameManager3D.Instance.CurrentBerryAmmo > 0) { Shoot(berryBombPrefab); BlockDrop_GameManager3D.Instance.ConsumeBerryAmmo(1); berryRegenTimer = berryRegenCooldown; } } private void Shoot(GameObject prefab) { if (prefab != null && muzzle != null) { Instantiate(prefab, muzzle.position, muzzle.rotation); } } }