diff --git a/Assets/Scripts/Inventory.cs b/Assets/Scripts/Inventory.cs
index 5ffbe7b5..656a3245 100644
--- a/Assets/Scripts/Inventory.cs
+++ b/Assets/Scripts/Inventory.cs
@@ -3,8 +3,7 @@ using System.Collections.Generic;
public class Inventory : MonoBehaviour
{
- // A fixed array of 10 slots
- [Header("Exactly 10 Slots")]
+ [Header("10 Inventory Slots")]
public Item[] slots = new Item[10];
public int currentSlot = 0;
@@ -25,9 +24,6 @@ public class Inventory : MonoBehaviour
}
}
- ///
- /// Adds an item to the first available slot (if any).
- ///
public void AddItem(Item newItem)
{
for (int i = 0; i < slots.Length; i++)
@@ -38,8 +34,6 @@ public class Inventory : MonoBehaviour
break;
}
}
- // Optional: if no item is equipped yet, equip slot 0, etc.
- // if (currentSpawnedItem == null) EquipSlot(0);
}
private void SelectNextSlot()
@@ -47,7 +41,6 @@ public class Inventory : MonoBehaviour
currentSlot = (currentSlot + 1) % slots.Length;
EquipSlot(currentSlot);
- // Force the UI to re-check which slot is active
var ui = FindObjectOfType();
if (ui != null)
{
diff --git a/Assets/Scripts/InventoryUI.cs b/Assets/Scripts/InventoryUI.cs
index d1fefd91..73362da1 100644
--- a/Assets/Scripts/InventoryUI.cs
+++ b/Assets/Scripts/InventoryUI.cs
@@ -3,10 +3,8 @@ using UnityEngine.UI;
public class InventoryUI : MonoBehaviour
{
- [SerializeField] private Image[] slotImages; // 10 UI Images
- [SerializeField] private Inventory inventory; // The fixed-slot Inventory
-
- // These let you pick highlight/normal colors in the Inspector
+ [SerializeField] private Image[] slotImages;
+ [SerializeField] private Inventory inventory;
[SerializeField] private Color normalColor = Color.white;
[SerializeField] private Color highlightColor = Color.yellow;
@@ -28,31 +26,26 @@ public class InventoryUI : MonoBehaviour
else
{
slotImages[i].sprite = null;
- slotImages[i].color = new Color(1,1,1,0); // or Color.clear
+ slotImages[i].color = new Color(1, 1, 1, 0);
}
}
- HighlightSlot(inventory.currentSlot); // after we set sprites, highlight the active slot
+ HighlightSlot(inventory.currentSlot);
}
private void HighlightSlot(int slotIndex)
{
- // Make sure it's a valid index
if (slotIndex < 0 || slotIndex >= slotImages.Length)
return;
- // Set all slots to normal color
for (int i = 0; i < slotImages.Length; i++)
{
- // If the slot is empty, you might want to leave it "clear"
- // but let's just do normalColor for demonstration:
if (slotImages[i].sprite == null)
- slotImages[i].color = new Color(1,1,1,0); // keep empty slot invisible
+ slotImages[i].color = new Color(1, 1, 1, 0);
else
slotImages[i].color = normalColor;
}
- // Now highlight the active slot
slotImages[slotIndex].color = highlightColor;
}
}
diff --git a/Assets/Scripts/PickUpKeyCard.cs b/Assets/Scripts/PickUpKeyCard.cs
index 5f7102ad..1ecdbe91 100644
--- a/Assets/Scripts/PickUpKeyCard.cs
+++ b/Assets/Scripts/PickUpKeyCard.cs
@@ -7,11 +7,11 @@ public class PickUpKeyCard : MonoBehaviour
private Outline outline;
[SerializeField] private Animator objectAnimator;
- [SerializeField] private string animationName = "PickupAnimation";
+ [SerializeField] private string animationName = "PickupAnimation";
[SerializeField] private AudioClip pickupSound = null;
[SerializeField] private string keyCardName = "Deck D key card";
- [SerializeField] private KeyCardPlayer keyCardPlayer = null;
+ [SerializeField] private KeyCardPlayer keyCardPlayer = null;
[SerializeField] private float interactionDistance = 5.0f;
[SerializeField] private Item keyCardItem;
@@ -48,22 +48,18 @@ public class PickUpKeyCard : MonoBehaviour
{
isPickedUp = true;
- // Mark key card as picked up in your custom script
if (keyCardPlayer != null)
keyCardPlayer.hasKeyCard = true;
- // Add the keycard to player's inventory
if (playerInventory != null && keyCardItem != null)
{
playerInventory.AddItem(keyCardItem);
- gameObject.SetActive(false);
- // Refresh the UI
InventoryUI inventoryUI = FindObjectOfType();
if (inventoryUI != null)
- {
inventoryUI.RefreshUI();
- }
+
+ Destroy(gameObject);
}
if (outline != null)
@@ -72,11 +68,9 @@ public class PickUpKeyCard : MonoBehaviour
if (interactionPrompt != null)
interactionPrompt.enabled = false;
- // Play pickup animation
if (objectAnimator != null)
objectAnimator.Play(animationName, 0, 0.0f);
- // Play sound
if (pickupSound != null)
SoundFXManager.instance.PlaySound(pickupSound, transform, 1.5f);
}