//-////////////////////////////////////////////////////
        ///
        /// Stores the item in the player's inventory and updates
        /// the inventory UI
        ///
        public bool StorePassiveItem(ItemPickUps_SO itemToStore)
        {
            if (itemToStore.isTemporal)
            {
                passiveItems.Add(itemToStore);
                passiveInventoryUI.CreateTemporalItemSlot(itemToStore.itemIcon, itemToStore.name, itemToStore.effectTime);
            }
            else
            {
                int itemToStoreIndex = FindPassiveItemIndex(itemToStore.name);

                // New Item
                if (itemToStoreIndex == -1)
                {
                    passiveItems.Add(itemToStore);
                    passiveInventoryUI.CreateItemSlot(itemToStore.itemIcon, itemToStore.name);
                }
                // Update existing item
                else
                {
                    passiveInventoryUI.UpdateItemSlot(itemToStoreIndex, itemToStore.itemIcon, itemToStore.name);
                }
            }

            // since we will always succed at storing a passive
            return(true);
        }
 //-////////////////////////////////////////////////////
 ///
 /// Sets up equip items for the start of the game
 ///
 private void InitialEquipment()
 {
     // given that the player starts up with a invenotry full of empty we handle itme equipment ourselves
     for (int i = 0; i < initialEquipment.Count; i++)
     {
         ItemPickUps_SO temp = ScriptableObject.Instantiate(initialEquipment[i]);
         equiptItems[i] = temp;
         equiptInventoryUI.UpdateItemSlot(i, temp.itemIcon, temp.name);
     }
 }
 //-////////////////////////////////////////////////////
 ///
 public bool StoreItem(ItemPickUps_SO itemToStore)
 {
     if (itemToStore.isEquipment)
     {
         return(AttemptStoreEquipmentItem(itemToStore));
     }
     else
     {
         return(StorePassiveItem(itemToStore));
     }
 }
        //-////////////////////////////////////////////////////
        ///
        private void CreateItem(ItemPickUps_SO itemToCreate)
        {
            Rigidbody itemSpawned = Instantiate(itemToCreate.itemSpawnObject, transform.position - new Vector3(1.5f, -1.5f, 1.5f), Quaternion.identity);

            Renderer itemMaterial = itemSpawned.GetComponent <Renderer>();

            itemMaterial.material = itemToCreate.itemMaterial;

            ItemPickUp itemType = itemSpawned.GetComponent <ItemPickUp>();

            itemType.itemDefinition = itemToCreate;
        }
        //-////////////////////////////////////////////////////
        ///
        public void DropEquipmentItem(StateManager stateManager)
        {
            int            index   = currentUnequipHover;
            ItemPickUps_SO oldItem = equiptItems[index];

            if (oldItem.itemName == "Empty")
            {
                return;
            }
            equiptItems[index] = emptyItem;
            equiptInventoryUI.UpdateItemSlot(index, equiptItems[index].itemIcon, equiptItems[index].name);

            CreateItem(oldItem);
        }
        //-////////////////////////////////////////////////////
        ///
        private bool AttemptStoreEquipmentItem(ItemPickUps_SO itemToStore)
        {
            int emptySlot    = AvailableSpaceInEquiptInventory();
            int repeatedItem = FindEquiptItemIndex(itemToStore.itemName);

            // (skill not equipt or it is equpt but not unqiue) and they have space
            if ((repeatedItem == -1 || equiptItems[repeatedItem].isUnique == false) && emptySlot != -1)
            {
                StoreEquipmentItem(itemToStore as ItemActivePickUps_SO, emptySlot);
                return(true);
            }
            else
            {
                Debug.Log("Can't Equipt, player already has it or full equipment");
                return(false);
                // Bring up the trading window system or just dont let them
            }
        }
示例#7
0
 void Start()
 {
     itemDefinition = ScriptableObject.Instantiate(itemDefinition);
 }