예제 #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
 void Start()
 {
     itemDefinition = ScriptableObject.Instantiate(itemDefinition);
 }