ccl4/blueberryPeak/Assets/Scripts/Player/TwigInteraction.cs
2025-06-19 01:07:40 +02:00

53 lines
1.2 KiB
C#

using System;
using Unity.Mathematics;
using UnityEngine;
using Random = UnityEngine.Random;
using AK.Wwise; // Make sure your Wwise namespace is correct
public class TwigInteraction : MonoBehaviour
{
private bool collected = false;
[SerializeField] private ItemReward twigReward;
[SerializeField] private AK.Wwise.Event pickupItem;
// Wwise Events
// public AK.Wwise.Event PlayBushesEvent;
// public AK.Wwise.Event PlayBerryWithBushEvent;
void Start()
{
if (collected)
{
Destroy(gameObject);
}
}
void OnTriggerEnter(Collider other)
{
if (!collected)
{
// Play the "Play_BerryWithBush" event if bush has berries
// PlayBerryWithBushEvent.Post(gameObject);
if (other.CompareTag("Player"))
{
other.gameObject.GetComponent<PlayerInteraction>()?.AddToInventory(twigReward);
Destroy(gameObject);
pickupItem.Post(gameObject);
collected = true;
}
}
}
public void SetCollected(bool picked)
{
collected = picked;
}
public bool IsCollected()
{
return collected;
}
}