using System.Collections; using System.Collections.Generic; using UnityEngine; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class Slot : MonoBehaviour { private Inventory inventory; // Reference to the Inventory script public int i; // Index of the slot in the inventory void Start() { // Find and get the Inventory component from the Player GameObject inventory = GameObject.FindGameObjectWithTag("Player").GetComponent(); } void Update() { // Check if the slot has no child items if (transform.childCount <= 0) { // Set the corresponding slot as not full in the Inventory inventory.isFull[i] = false; } } // Method to drop items from the slot public void DropItem() { // Iterate through each child item in the slot foreach (Transform child in transform) { // Call the SpawnDroppedItem method on the item's Spawn component child.GetComponent().SpawnDroppedItem(); // Destroy the item GameObject GameObject.Destroy(child.gameObject); } } }