using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class RingInventory : MonoBehaviour { [Header("Inventory standard")] public Transform pivot; public Transform angleForFirstItem; public Transform inventoryParentAfterOpening; public Transform inventoryOriginalParent; [Header("Inventory Collectables")] public Transform collectablesPivot; //public Vector3 inventoryOriginalPos; //public Quaternion inventoryOriginalRot; public float radius = 2f; public float smoothSpeed = 5f; public float fixedYPosition = 0f; public List items; public List collectableItems; public int currentIndex = 0; public int collectablesCurrentIndex = 0; public float targetAngle = 0f; public float fixedAngle = -90f; [SerializeField] private AudioClip[] inventoryNextItemAudioClip; [Header("UI")] public TextMeshProUGUI itemName; [SerializeField] private string[] itemsNames; public TextMeshProUGUI itemDescription; [SerializeField] private string[] itemDescriptions; public bool shouldTakeInput = true; public bool canPressButton = true; public int previousIndex; public int previousCollectableItemIndex; private static RingInventory _instance; public static RingInventory GetInstance() { return _instance; } void Awake() { if (!_instance) { _instance = this; } } public int CurrentIndex { get { return currentIndex; } } void Start() { //inventoryOriginalPos = InventoryManager.GetInstance().inventoryCanvas.transform.position; //inventoryOriginalRot = InventoryManager.GetInstance().inventoryCanvas.transform.rotation; #region Old version //// Position items around the pivot //int itemCount = transform.childCount; //items = new Transform[itemCount]; //float angle = 360f / itemCount; //print(itemCount + "Item count"); //for (int i = 0; i < itemCount; i++) //{ // items[i] = transform.GetChild(i); // float angleInRadians = Mathf.Deg2Rad * (360f - angle * i); // Decrease angle for clockwise rotation // Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); //} #endregion #region old //int itemCount = transform.childCount; //items = new Transform[itemCount]; //// Calculate the angle adjustment based on the player's rotation //float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; //for (int i = 0; i < itemCount; i++) //{ // items[i] = transform.GetChild(i); // // Calculate the angle for this item // float angle = 360f / itemCount * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // //// Calculate the position with Y position set to zero // //Vector3 position = new Vector3(radius * Mathf.Sin(angleInRadians), 0f, radius * Mathf.Cos(angleInRadians)); // Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // // Set the item's position relative to the pivot // //items[i].position = pivot.position + position; // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); //} //int itemCount = transform.childCount; //// Calculate the angle adjustment based on the camera's rotation //float angleOffset = PlayerManager.GetInstance().PlayerMainCamera.transform.rotation.eulerAngles.y; //// Iterate through the children of the parent transform and add them to the list //foreach (Transform child in transform) //{ // items.Add(child); //} //for (int i = 0; i < itemCount; i++) //{ // // Calculate the angle for this item // float angle = 360f / itemCount * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // // Set the item's position relative to the pivot // //items[i].position = pivot.position + position; // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); //} #endregion #region NEW BUT TESTING THE COLLECTIBLES INVENTORY //int itemCount = transform.childCount; //// Calculate the angle adjustment based on the camera's rotation //float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; //foreach (Transform child in transform) //{ // items.Add(child); //} //// Define the position for the first item //Vector3 firstItemPosition = pivot.position; // Change this to your desired position //// Calculate the angle between items //float angleStep = -360f / itemCount; //for (int i = 0; i < itemCount; i++) //{ // // Calculate the angle for this item // float angle = angleStep * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // // Calculate the position for each item in a circle with equal spacing // Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // // Set the item's Y position to be fixed // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); //} //#region UI //items[currentIndex].GetComponent().UpdateItemDescription(); //#endregion //items[currentIndex].GetComponent().enabled = true; ////RefreshItemsOnInventory(itemCount); //InventoryManager.GetInstance().inventoryCanvas.SetActive(false); #endregion //InventoryInitialisation(currentIndex, pivot, items); //InventoryInitialisation(collectablesCurrentIndex, collectablesPivot, collectableItems); } public void CleanItemNameAndDescription() { itemName.text = ""; itemDescription.text = ""; } public void InventoryInitialisationForKeysAndItemsAndCollectables() { InventoryInitialisation(currentIndex, pivot, items); InventoryInitialisation(collectablesCurrentIndex, collectablesPivot, collectableItems); } void InventoryInitialisation(int currentItemIndex, Transform pivot, List items) { int itemCount = pivot.childCount; // Calculate the angle adjustment based on the camera's rotation float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; foreach (Transform child in pivot) { items.Add(child); } // Define the position for the first item Vector3 firstItemPosition = pivot.position; // Change this to your desired position // Calculate the angle between items float angleStep = -360f / itemCount; for (int i = 0; i < itemCount; i++) { // Calculate the angle for this item float angle = angleStep * i + angleOffset; // Convert the angle to radians float angleInRadians = Mathf.Deg2Rad * angle; // Calculate the position for each item in a circle with equal spacing Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); items[i].position = position; // Set the item's Y position to be fixed items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); } #region UI items[currentItemIndex].GetComponent().UpdateItemDescription(); #endregion items[currentItemIndex].GetComponent().enabled = true; //RefreshItemsOnInventory(itemCount); InventoryManager.GetInstance().inventoryCanvas.SetActive(false); print("Inventory Initialized gurl"); } public void UpdateUIElementsForKeysAndItemsInventory() { UpdateUIElements(items, currentIndex); } public void UpdateUIElementsForCollectablesInventory() { UpdateUIElements(collectableItems, collectablesCurrentIndex); } public void UpdateUIElements(List items, int currentIndex) { items[currentIndex].GetComponent().UpdateItemDescription(); } public enum InventoryState { None, KeysAndItemsInventory, CollectablesInventory } public InventoryState inventoryState = InventoryState.None; public bool IsOnState(InventoryState checkState) { return inventoryState == checkState; } public void GoToKeysAndItemsInventory() { inventoryState = InventoryState.KeysAndItemsInventory; } public void GoToCollectablesInventory() { inventoryState = InventoryState.CollectablesInventory; } public void GoToNone() { inventoryState = InventoryState.None; } void Update() { // Check for right arrow key press if (canPressButton && InventoryManager.GetInstance().IsOnState(InventoryManager.State.CollectablesMenu) == false) { float DpadHorizontal = Input.GetAxis("DpadHorizontal"); if (shouldTakeInput) { if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D) || DpadHorizontal < 0) { #region NEW BUT TESTING COLLECTABLE INVENTORY CATEGORY //previousIndex = currentIndex; //currentIndex++; //if (currentIndex >= items.Count) // currentIndex = 0; //// Calculate target angle //float angle = 360f / items.Count; //targetAngle = angle * currentIndex; //items[previousIndex].GetComponent().enabled = false; //items[currentIndex].GetComponent().enabled = true; //items[currentIndex].GetComponent().UpdateItemDescription(); //StartCoroutine(InputDelay()); //PlayNextItemAudioClip(); #endregion if (inventoryState == InventoryState.KeysAndItemsInventory) NextInventoryItem(ref currentIndex, ref previousIndex, items); else if (inventoryState == InventoryState.CollectablesInventory) NextInventoryItem(ref collectablesCurrentIndex, ref previousCollectableItemIndex, collectableItems); StartCoroutine(InputUpdate()); } // Check for left arrow key press else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A) || DpadHorizontal > 0) { #region NEW BUT TESTING COLLECTABLE INVENTORY CATEGORY //previousIndex = currentIndex; //currentIndex--; //if (currentIndex < 0) // currentIndex = items.Count - 1; //// Calculate target angle //float angle = 360f / items.Count; //targetAngle = angle * currentIndex; //items[previousIndex].GetComponent().enabled = false; //items[currentIndex].GetComponent().enabled = true; //items[currentIndex].GetComponent().UpdateItemDescription(); //StartCoroutine(InputDelay()); //PlayNextItemAudioClip(); #endregion if (inventoryState == InventoryState.KeysAndItemsInventory) PreviousInventoryItem(ref currentIndex, ref previousIndex, items); else if (inventoryState == InventoryState.CollectablesInventory) PreviousInventoryItem(ref collectablesCurrentIndex, ref previousCollectableItemIndex, collectableItems); StartCoroutine(InputUpdate()); } } } if (InventoryManager.GetInstance().inventoryIsOpen) { // Smoothly rotate towards the target angle Quaternion targetRotation = Quaternion.Euler(0f, targetAngle + fixedAngle, 0f); if (inventoryState == InventoryState.KeysAndItemsInventory) { pivot.localRotation = Quaternion.Lerp(pivot.localRotation, targetRotation, smoothSpeed * Time.unscaledDeltaTime); } else if (inventoryState == InventoryState.CollectablesInventory) { collectablesPivot.localRotation = Quaternion.Lerp(collectablesPivot.localRotation, targetRotation, smoothSpeed * Time.unscaledDeltaTime); } } //When player presses ENTER OR the controller input: if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton0)) { #region NEW BUT TESTING THE COLLECTIBLES INVENTORY //items[currentIndex].GetComponent().UseItem(); if (inventoryState == InventoryState.KeysAndItemsInventory) UseCurrentItem(currentIndex, items); else if (inventoryState == InventoryState.CollectablesInventory) UseCurrentItem(collectablesCurrentIndex, collectableItems); #endregion } #region Update UI //itemName.text = itemsNames[currentIndex]; //itemDescription.text = itemDescriptions[currentIndex]; #endregion } IEnumerator InputUpdate() { InventoryManager.GetInstance().canChangeInventoryState = false; shouldTakeInput = false; yield return new WaitForSecondsRealtime(0.2f); shouldTakeInput = true; InventoryManager.GetInstance().canChangeInventoryState = true; } private void UseCurrentItem(int currentIndex, List items) { items[currentIndex].GetComponent().UseItem(); } private void NextInventoryItem(ref int currentIndex, ref int previousIndex, List items) { previousIndex = currentIndex; currentIndex++; if (currentIndex >= items.Count) currentIndex = 0; // Calculate target angle float angle = 360f / items.Count; targetAngle = angle * currentIndex; items[previousIndex].GetComponent().enabled = false; items[currentIndex].GetComponent().enabled = true; items[currentIndex].GetComponent().UpdateItemDescription(); StartCoroutine(InputDelay()); PlayNextItemAudioClip(); } private void PreviousInventoryItem(ref int currentIndex, ref int previousIndex, List items) { previousIndex = currentIndex; currentIndex--; if (currentIndex < 0) currentIndex = items.Count - 1; // Calculate target angle float angle = 360f / items.Count; targetAngle = angle * currentIndex; items[previousIndex].GetComponent().enabled = false; items[currentIndex].GetComponent().enabled = true; items[currentIndex].GetComponent().UpdateItemDescription(); StartCoroutine(InputDelay()); PlayNextItemAudioClip(); } /// /// When you need to re Update the description in case you cleaned it. /// public void UpdateItemDescription() { if (inventoryState == InventoryState.KeysAndItemsInventory) items[currentIndex].GetComponent().UpdateItemDescription(); else if (inventoryState == InventoryState.CollectablesInventory) collectableItems[collectablesCurrentIndex].GetComponent().UpdateItemDescription(); } IEnumerator InputDelay() { canPressButton = false; yield return new WaitForSecondsRealtime(0.2f); canPressButton = true; } private void PlayNextItemAudioClip() { InventoryManager.GetInstance().inventoryAudioSource.PlayOneShot(inventoryNextItemAudioClip[Random.Range(0, inventoryNextItemAudioClip.Length)]); } //public void AddItem(Transform newItem) //{ // ////InventoryManager.GetInstance().inventoryCanvas.SetActive(true); // //// Set the parent of the new item as the inventory container // //newItem.SetParent(transform); // //// Calculate the position for the new item // //int itemCount = items.Length + 1; // //#region Old shit // ////float angle = 360f / itemCount; // ////float angleInRadians = Mathf.Deg2Rad * angle * (items.Length - 1); // ////Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // ////newItem.position = position; // //#endregion // //// Add the new item to the items array // //Transform[] newItems = new Transform[itemCount]; // //items.CopyTo(newItems, 0); // //newItems[itemCount - 1] = newItem; // //items = newItems; // //int i = 0; // //for (i = 0; i < items.Length; i++) // //{ // // items[i].transform.localPosition = Vector3.zero; // // items[i].transform.rotation = new Quaternion(0, 0, 0, 0); // //} // //if (i == items.Length) // //{ // // print(items.Length /*- 1*/ + "Items length"); // // RefreshItemsOnInventory(itemCount); // //} // newItem.SetParent(transform); // items.Add(newItem); // Putsa(); //} // Function to add a new item to the list public void AddItemToKeysAndItemsInventory(Transform newItem) { AddItem(newItem,items,pivot,currentIndex); } public void AddItemToCollectablesInventory(Transform newItem) { AddItem(newItem, collectableItems, collectablesPivot, collectablesCurrentIndex); } public void RemoveItemByNameToKeysAndItemsInventory(string itemName) { RemoveItemByName(itemName, items, pivot, currentIndex); } public void RemoveItemByNameToCollectablesInventory(string itemName) { RemoveItemByName(itemName, collectableItems, collectablesPivot, collectablesCurrentIndex); } public void RefreshItemsToKeysAndItemsInventory() { RefreshItems(items,pivot,currentIndex); } public void RefreshItemsToCollectablesInventory() { RefreshItems(collectableItems, collectablesPivot, collectablesCurrentIndex); } public void AddItem(Transform newItem, List items, Transform pivot, int currentIndex) { float angleOffset = PlayerManager.GetInstance().PlayerMainCamera.transform.rotation.eulerAngles.y; newItem.SetParent(pivot); items.Add(newItem); // Add the new item int itemCount = items.Count; // Define the position for the first item Vector3 firstItemPosition = pivot.position; // Change this to your desired position // Calculate the angle between items float angleStep = -360f / itemCount; int i = 0; for (i = 0; i < itemCount; i++) { // Calculate the angle for this item float angle = angleStep * i + angleOffset; // Convert the angle to radians float angleInRadians = Mathf.Deg2Rad * angle; // Calculate the position for each item in a circle with equal spacing Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); items[i].position = position; // Set the item's Y position to be fixed items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); } #region UI items[currentIndex].GetComponent().UpdateItemDescription(); #endregion items[currentIndex].GetComponent().enabled = true; } public void RemoveItemByName(string itemName, List items, Transform pivot, int currentIndex) { Transform itemToRemove = items.Find(item => item.name == itemName); if (itemToRemove != null) { int itemIndex = items.IndexOf(itemToRemove); // Remove the item from the items list items.RemoveAt(itemIndex); print("REMOVED Item Index: " + itemIndex); // Set false the item's GameObject and change the parent. itemToRemove.gameObject.SetActive(false); itemToRemove.transform.SetParent(InventoryManager.GetInstance().itemsToAddTransform); // Optionally, you can refresh the items' positions and update the UI RefreshItems(items, pivot, currentIndex); UpdateUIElements(items, currentIndex); } } public void RefreshItems(List items, Transform pivot, int currentIndex) { int itemCount = pivot.childCount; // Calculate the angle adjustment based on the camera's rotation float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; // Define the position for the first item Vector3 firstItemPosition = pivot.position; // Change this to your desired position // Calculate the angle between items float angleStep = -360f / itemCount; int i = 0; for (i = 0; i < itemCount; i++) { // Calculate the angle for this item float angle = angleStep * i + angleOffset; // Convert the angle to radians float angleInRadians = Mathf.Deg2Rad * angle; // Calculate the position for each item in a circle with equal spacing Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); items[i].position = position; // Set the item's Y position to be fixed items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); } #region UI items[currentIndex].GetComponent().UpdateItemDescription(); #endregion items[currentIndex].GetComponent().enabled = true; InventoryManager.GetInstance().inventoryCanvas.transform.SetParent(inventoryParentAfterOpening); InventoryManager.GetInstance().inventoryCanvas.transform.localPosition = Vector3.zero; InventoryManager.GetInstance().inventoryCanvas.transform.rotation = new Quaternion(0, 0, 0, 0); } #region NEW BUT TESTING COLLECTABLES CATEGORY //public void AddItem(Transform newItem) //{ // //InventoryManager.GetInstance().inventoryCanvas.SetActive(true); // float angleOffset = PlayerManager.GetInstance().PlayerMainCamera.transform.rotation.eulerAngles.y; // newItem.SetParent(transform); // items.Add(newItem); // Add the new item // int itemCount = items.Count; // // Define the position for the first item // Vector3 firstItemPosition = pivot.position; // Change this to your desired position // // Calculate the angle between items // float angleStep = -360f / itemCount; // int i = 0; // for ( i = 0; i < itemCount; i++) // { // // Calculate the angle for this item // float angle = angleStep * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // // Calculate the position for each item in a circle with equal spacing // Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // // Set the item's Y position to be fixed // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); // } // #region UI // items[currentIndex].GetComponent().UpdateItemDescription(); // #endregion // items[currentIndex].GetComponent().enabled = true; // //if(i == items.Count) // //{ // // InventoryManager.GetInstance().inventoryCanvas.SetActive(false); // //} // //InventoryManager.GetInstance().inventoryCanvas.SetActive(false); //} //public void RemoveItem(int itemIndex) //{ // if (itemIndex >= 0 && itemIndex < items.Count) // { // Transform itemToRemove = items[itemIndex]; // // Remove the item from the items list // items.RemoveAt(itemIndex); // // Destroy the item's GameObject to remove it from the scene // itemToRemove.gameObject.SetActive(false); // itemToRemove.transform.SetParent(InventoryManager.GetInstance().itemsToAddTransform); // // Optionally, you can refresh the items' positions and update the UI // RefreshItems(); // UpdateUIElements(); // } //} //public void RemoveItemByName(string itemName) //{ // Transform itemToRemove = items.Find(item => item.name == itemName); // if (itemToRemove != null) // { // int itemIndex = items.IndexOf(itemToRemove); // // Remove the item from the items list // items.RemoveAt(itemIndex); // // Set false the item's GameObject and change the parent. // itemToRemove.gameObject.SetActive(false); // itemToRemove.transform.SetParent(InventoryManager.GetInstance().itemsToAddTransform); // // Optionally, you can refresh the items' positions and update the UI // RefreshItems(); // UpdateUIElements(); // } //} //public void RefreshItems() //{ // int itemCount = transform.childCount; // // Calculate the angle adjustment based on the camera's rotation // float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; // // Define the position for the first item // Vector3 firstItemPosition = pivot.position; // Change this to your desired position // // Calculate the angle between items // float angleStep = -360f / itemCount; // int i = 0; // for (i = 0; i < itemCount; i++) // { // // Calculate the angle for this item // float angle = angleStep * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // // Calculate the position for each item in a circle with equal spacing // Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // items[i].position = position; // // Set the item's Y position to be fixed // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); // } // #region UI // items[currentIndex].GetComponent().UpdateItemDescription(); // #endregion // items[currentIndex].GetComponent().enabled = true; // InventoryManager.GetInstance().inventoryCanvas.transform.SetParent(inventoryParentAfterOpening); // InventoryManager.GetInstance().inventoryCanvas.transform.localPosition = Vector3.zero; // InventoryManager.GetInstance().inventoryCanvas.transform.rotation = new Quaternion(0, 0, 0, 0); //} #endregion private void Putsa() { int itemCount = transform.childCount; // Calculate the angle adjustment based on the camera's rotation float angleOffset = PlayerManager.GetInstance().PlayerMainCamera.transform.rotation.eulerAngles.y; //foreach (Transform child in transform) //{ // items.Add(child); //} // Define the position for the first item Vector3 firstItemPosition = pivot.position; // Change this to your desired position // Calculate the angle between items float angleStep = 360f / itemCount; for (int i = 0; i < itemCount; i++) { // Calculate the angle for this item float angle = angleStep * i + angleOffset; // Convert the angle to radians float angleInRadians = Mathf.Deg2Rad * angle; // Calculate the position for each item in a circle with equal spacing Vector3 position = firstItemPosition + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); items[i].position = position; // Set the item's Y position to be fixed items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); } #region UI items[currentIndex].GetComponent().UpdateItemDescription(); #endregion items[currentIndex].GetComponent().enabled = true; } //private void RefreshItemsOnInventory(int itemCount) //{ // //targetAngle = 0f; // //currentIndex = 0; // //pivot.rotation = new Quaternion(0, 0, 0, 0); // ////// Position items around the pivot // //itemCount = transform.childCount; // //items = new Transform[itemCount]; // //float angle = 360f / itemCount; // //for (int i = 0; i < itemCount; i++) // //{ // // items[i] = transform.GetChild(i); // // float angleInRadians = Mathf.Deg2Rad * (360f - angle * i); // Decrease angle for clockwise rotation // // Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // // items[i].position = position; // // items[i].localPosition = new Vector3(items[i].localPosition.x, fixedYPosition, items[i].localPosition.z); // //} // itemCount = transform.childCount; // items = new Transform[itemCount]; // for (int i = 0; i < itemCount; i++) // { // items[i] = transform.GetChild(i); // // Calculate the angle adjustment based on the player's rotation // float angleOffset = PlayerManager.GetInstance().playerGameObj.transform.rotation.eulerAngles.y; // // Calculate the angle for this item // float angle = 360f / itemCount * i + angleOffset; // // Convert the angle to radians // float angleInRadians = Mathf.Deg2Rad * angle; // // Calculate the position // Vector3 position = pivot.position + new Vector3(radius * Mathf.Sin(angleInRadians), fixedYPosition, radius * Mathf.Cos(angleInRadians)); // // Set the item's position // items[i].position = position; // } // #region UI // items[currentIndex].GetComponent().UpdateItemDescription(); // #endregion // items[currentIndex].GetComponent().enabled = true; // //InventoryManager.GetInstance().inventoryCanvas.SetActive(false); //} public void ResetInventoryValuesOnClose() { targetAngle = 0f; currentIndex = 0; pivot.rotation = new Quaternion(0, 0, 0, 0); collectablesCurrentIndex = 0; collectablesPivot.rotation = new Quaternion(0, 0, 0, 0); } }