From 4464383a4db1b15d5e35aa94e17716363e4bd573 Mon Sep 17 00:00:00 2001 From: AgentSchmisch Date: Tue, 17 Jun 2025 14:25:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20altered=20BushInteraction.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Scripts/BushInteraction.cs | 63 ++++++++++++++----- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/blueberryPeak/Assets/Scripts/BushInteraction.cs b/blueberryPeak/Assets/Scripts/BushInteraction.cs index 097ee91..3f296a1 100644 --- a/blueberryPeak/Assets/Scripts/BushInteraction.cs +++ b/blueberryPeak/Assets/Scripts/BushInteraction.cs @@ -6,9 +6,22 @@ using AK.Wwise; // Make sure your Wwise namespace is correct public class BushInteraction : MonoBehaviour { + [SerializeField] private int blueberryCount; + +#if UNITY_EDITOR + void OnValidate() + { + if (blueberryCount > 0) + { + // If the UID is already set, we don't need to do anything + return; + } + // Generate a new UID based on the position of the object + blueberryCount = Random.Range(1, 5); + } +#endif [SerializeField] private GameObject emptyBush; - private int blueberryCount = 0; private bool BlueBerriesPicked = false; // Wwise Events @@ -17,7 +30,6 @@ public class BushInteraction : MonoBehaviour void Start() { - blueberryCount = Random.Range(1, 5); // Randomly initialize blueberry count between 1 and 5 } void OnTriggerEnter(Collider other) @@ -33,19 +45,42 @@ public class BushInteraction : MonoBehaviour PlayBerryWithBushEvent.Post(gameObject); other.gameObject.GetComponent().CollectBlueberry(blueberryCount); - - Vector3 currentPosition = transform.position; - Quaternion currentRotation = transform.rotation; - Transform parent = transform.parent; - - Destroy(gameObject); - - GameObject _emptyBush = Instantiate(emptyBush, currentPosition, currentRotation); - // Optionally assign parent if needed - // _emptyBush.transform.parent = parent; - + ChangeBushAppearance(); + blueberryCount = 0; BlueBerriesPicked = true; } - + + } + public int GetBlueberryCount() + { + return blueberryCount; + } + public void SetBlueberryCount(int count) + { + blueberryCount = count; + if (blueberryCount == 0 && BlueBerriesPicked) + { + ChangeBushAppearance(); + } + } + public void ChangeBushAppearance() + { + Vector3 currentPosition = transform.position; + Quaternion currentRotation = transform.rotation; + Transform parent = transform.parent; + + Destroy(gameObject); + + GameObject _emptyBush = Instantiate(emptyBush, currentPosition, currentRotation); + + } + + public void SetBlueberriesPicked(bool picked) + { + BlueBerriesPicked = picked; + } + public bool AreBlueberriesPicked() + { + return BlueBerriesPicked; } } \ No newline at end of file