public bool EquipmentSlotToggled(EquipmentSlot es) { if (SelectedSlot == -1) { return(false); } //Get the data from currently selected item InventorySlot firstItem = slots[this.SelectedSlot].GetComponent <InventorySlot>(); //Check if this is the correct slot and check if we got if (firstItem.Item.Stats.EquipmentType != es.SlotAcceptType) { return(false); } //Check if both are invalid item, then just dont do anything if (es.Item.ID == -1 && firstItem.Item.ID == -1) { firstItem.setActiveNoInventoyCall(false); return(false); } //Create temp variables ItemObject tempFirstObject = firstItem.Item; Vector3 tempPosFirst = firstItem.transform.GetChild(0).position; Vector3 tempPosSecond = es.transform.GetChild(0).position; //Check if the selecte inventory slot is empty, if so just swap the items normally if (firstItem.Item.ID == -1 || firstItem.Amount == 1) { //Update first item firstItem.Item = es.Item; firstItem.Amount = 1; //Update equipment item es.Item = tempFirstObject; //Fix positions es.transform.GetChild(0).position = tempPosFirst; firstItem.transform.GetChild(0).position = tempPosSecond; firstItem.transform.GetChild(0).SetParent(es.transform); es.transform.GetChild(0).SetParent(firstItem.transform); return(true); } //Check if we currently got an item equiped, if now, just reduce the quantity by 1, and add the item to the slot, if we do, just add the current equiped to the inventory if (es.Item.ID == -1 || AddItem(es.Item.ID)) { //Update equipment item es.Item = firstItem.Item; es.UpdateStatus(); //Remove one from the amount and update firstItem.Amount--; firstItem.UpdateStatus(); return(true); } return(false); }