コード例 #1
0
        //-////////////////////////////////////////////////////
        ///
        /// 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);
        }
コード例 #2
0
 //-////////////////////////////////////////////////////
 ///
 /// 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);
     }
 }
コード例 #3
0
 //-////////////////////////////////////////////////////
 ///
 public bool StoreItem(ItemPickUps_SO itemToStore)
 {
     if (itemToStore.isEquipment)
     {
         return(AttemptStoreEquipmentItem(itemToStore));
     }
     else
     {
         return(StorePassiveItem(itemToStore));
     }
 }
コード例 #4
0
        //-////////////////////////////////////////////////////
        ///
        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;
        }
コード例 #5
0
        //-////////////////////////////////////////////////////
        ///
        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);
        }
コード例 #6
0
        //-////////////////////////////////////////////////////
        ///
        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
ファイル: ItemPickUp.cs プロジェクト: LunaLuna7/ItemSystem
 void Start()
 {
     itemDefinition = ScriptableObject.Instantiate(itemDefinition);
 }