public void OnPointerDown(PointerEventData data) { if (inventory != null) { if (item.Type < 6) { //item is equippable string s = Enum.GetName(typeof(ItemType), item.Type); if (inventory.equipSlots[item.Type] == null) { GameObject inventoryItem = this.gameObject; inventory.equipSlots[item.Type] = inventoryItem; GameObject charSlot = inventory.charPanel.transform.GetChild(0).GetChild(item.Type).gameObject; inventoryItem.transform.SetParent(charSlot.transform); inventoryItem.GetComponent <RectTransform>().localPosition = Vector3.zero; Debug.Log("Item Equipped"); } inventory.EquipItem(item); } if (item.Type == 6) { //item is consumable int amount; inventory.ConsumeItem(item); amount = inventory.RemoveItem(item); if (amount == 0) { Destroy(gameObject); } } } }
public void UseItemNotificationResult(bool result) { GameManager.instance.uiActive = false; if (result == true) { inventory.ConsumeItem(); } }
public static void GiveItemFromSelectBox(GameSession session, Item sourceItem, int index) { SelectItemBox box = sourceItem.Function.SelectItemBox; ItemDropMetadata metadata = ItemDropMetadataStorage.GetItemDropMetadata(box.BoxId); if (metadata == null) { session.Send(NoticePacket.Notice("No items found", NoticeType.Chat)); return; } Inventory inventory = session.Player.Inventory; inventory.ConsumeItem(session, sourceItem.Uid, 1); // Select boxes disregards group ID. Adding these all to a filtered list List <DropGroupContent> dropContentsList = new(); foreach (DropGroup group in metadata.DropGroups) { foreach (DropGroupContent dropGroupContent in group.Contents) { if (dropGroupContent.SmartDropRate == 100) { List <Job> recommendJobs = ItemMetadataStorage.GetRecommendJobs(dropGroupContent.ItemIds.First()); if (recommendJobs.Contains(session.Player.Job) || recommendJobs.Contains(Job.None)) { dropContentsList.Add(dropGroupContent); } continue; } dropContentsList.Add(dropGroupContent); } } DropGroupContent dropContents = dropContentsList[index]; Random rng = RandomProvider.Get(); int amount = rng.Next((int)dropContents.MinAmount, (int)dropContents.MaxAmount); foreach (int id in dropContents.ItemIds) { Item newItem = new(id) { Enchants = dropContents.EnchantLevel, Amount = amount, Rarity = dropContents.Rarity }; inventory.AddItem(session, newItem, true); } }
public override bool Activate() { var itemAmount = Inventory != null?Inventory.GetItemAmount(Definition.Id) : 0; bool available = itemAmount > 0; if (available) { var character = MySession.Static.ControlledEntity as MyCharacter; itemAmount = MyFixedPoint.Min(itemAmount, 1); if (character != null && itemAmount > 0) { Inventory.ConsumeItem(Definition.Id, itemAmount, character.EntityId); } } return(true); }
private static void ConsumeMaterials(GameSession session, int greenCrystalCost, int metacellCosts, int crystalFragmentsCosts, List <KeyValuePair <long, Item> > greenCrystals, List <KeyValuePair <long, Item> > metacells, List <KeyValuePair <long, Item> > crystalFragments) { Inventory inventory = session.Player.Inventory; foreach ((long uid, Item item) in greenCrystals) { if (item.Amount >= greenCrystalCost) { inventory.ConsumeItem(session, uid, greenCrystalCost); break; } greenCrystalCost -= item.Amount; inventory.ConsumeItem(session, uid, item.Amount); } foreach ((long uid, Item item) in metacells) { if (item.Amount >= metacellCosts) { inventory.ConsumeItem(session, uid, metacellCosts); break; } metacellCosts -= item.Amount; inventory.ConsumeItem(session, uid, item.Amount); } foreach ((long uid, Item item) in crystalFragments) { if (item.Amount >= crystalFragmentsCosts) { inventory.ConsumeItem(session, uid, crystalFragmentsCosts); break; } crystalFragmentsCosts -= item.Amount; inventory.ConsumeItem(session, uid, item.Amount); } }
public void consumeIt() { Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); bool gearable = false; if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { eS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); inventory.EquiptItem(item); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } }
public void OnPointerDown(PointerEventData data) { if (this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() == null) { bool gearable = false; Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } if (data.button == PointerEventData.InputButton.Right) { //item from craft system to inventory if (transform.parent.GetComponent <CraftResultSlot>() != null) { bool check = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>().checkIfItemAllreadyExist(item.itemID, item.itemValue); if (!check) { GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>().addItemToInventory(item.itemID, item.itemValue); GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>().stackableSettings(); } CraftSystem cS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.GetComponent <CraftSystem>(); cS.deleteItems(item); CraftResultSlot result = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.transform.GetChild(3).GetComponent <CraftResultSlot>(); result.temp = 0; //tooltip.deactivateTooltip(); gearable = true; GameObject.FindGameObjectWithTag("MainInventory").GetComponent <Inventory>().updateItemList(); } else { bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; if (eS.transform.GetChild(1).GetChild(i).parent.parent.GetComponent <EquipmentSystem>() != null && this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() != null) { } else { inventory.EquiptItem(item); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } } } }
private static void HandleUnlockSocket(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); byte fodderAmount = packet.ReadByte(); List <long> fodderUids = new(); for (int i = 0; i < fodderAmount; i++) { long fodderUid = packet.ReadLong(); fodderUids.Add(fodderUid); } Inventory inventory = session.Player.Inventory; if (!inventory.Items.ContainsKey(itemUid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } Item equip = inventory.Items[itemUid]; int equipUnlockedSlotCount = equip.Stats.GemSockets.Count(x => x.IsUnlocked); foreach (long uid in fodderUids) { if (!inventory.Items.ContainsKey(uid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } Item fodder = inventory.Items[uid]; int fodderUnlockedSlotCount = fodder.Stats.GemSockets.Count(x => x.IsUnlocked); if (equipUnlockedSlotCount == fodderUnlockedSlotCount) { continue; } session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.CannotBeUsedAsMaterial)); return; } // get socket slot to unlock int slot = equip.Stats.GemSockets.FindIndex(0, equip.Stats.GemSockets.Count, x => !x.IsUnlocked); if (slot < 0) { return; } // fragmment cost. hard coded into the client? int crystalFragmentCost = 0; if (slot == 0) { crystalFragmentCost = 400; } else if (slot is 1 or 2) { crystalFragmentCost = 600; } int crystalFragmentsTotalAmount = 0; List <KeyValuePair <long, Item> > crystalFragments = inventory.Items.Where(x => x.Value.Tag == "CrystalPiece").ToList(); crystalFragments.ForEach(x => crystalFragmentsTotalAmount += x.Value.Amount); if (crystalFragmentsTotalAmount < crystalFragmentCost) { return; } foreach ((long uid, Item item) in crystalFragments) { if (item.Amount >= crystalFragmentCost) { inventory.ConsumeItem(session, uid, crystalFragmentCost); break; } crystalFragmentCost -= item.Amount; inventory.ConsumeItem(session, uid, item.Amount); } foreach (long uid in fodderUids) { inventory.ConsumeItem(session, uid, 1); } equip.Stats.GemSockets[slot].IsUnlocked = true; List <GemSocket> unlockedSockets = equip.Stats.GemSockets.Where(x => x.IsUnlocked).ToList(); session.Send(ItemSocketSystemPacket.UnlockSocket(equip, (byte)slot, unlockedSockets)); }
private static void HandleUpgradeGem(GameSession session, PacketReader packet) { long equipUid = packet.ReadLong(); byte slot = packet.ReadByte(); long itemUid = packet.ReadLong(); ItemGemstoneUpgradeMetadata metadata; Inventory inventory = session.Player.Inventory; if (equipUid == 0) // this is a gemstone in the player's inventory { if (!inventory.Items.ContainsKey(itemUid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } Item gem = inventory.Items[itemUid]; if (gem == null) { return; } metadata = ItemGemstoneUpgradeMetadataStorage.GetMetadata(gem.Id); if (metadata == null || metadata.NextItemId == 0) { return; } if (!CheckGemUpgradeIngredients(inventory, metadata)) { return; } ConsumeIngredients(session, metadata); inventory.ConsumeItem(session, gem.Uid, 1); Item upgradeGem = new(metadata.NextItemId) { Rarity = gem.Rarity }; inventory.AddItem(session, upgradeGem, true); session.Send(ItemSocketSystemPacket.UpgradeGem(equipUid, slot, upgradeGem)); return; } // upgrade gem mounted on a equipment if (!inventory.Items.ContainsKey(equipUid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } Gemstone gemstone = inventory.Items[equipUid].Stats.GemSockets[slot].Gemstone; if (gemstone == null) { return; } metadata = ItemGemstoneUpgradeMetadataStorage.GetMetadata(gemstone.Id); if (metadata == null || metadata.NextItemId == 0) { return; } if (!CheckGemUpgradeIngredients(inventory, metadata)) { return; } ConsumeIngredients(session, metadata); Item newGem = new(metadata.NextItemId) { IsLocked = gemstone.IsLocked, UnlockTime = gemstone.UnlockTime }; Player owner = GameServer.PlayerManager.GetPlayerById(gemstone.OwnerId); if (owner != null) { newGem.OwnerCharacterId = owner.CharacterId; newGem.OwnerCharacterName = owner.Name; } Gemstone upgradedGemstone = new() { Id = metadata.NextItemId, IsLocked = gemstone.IsLocked, UnlockTime = gemstone.UnlockTime, OwnerId = gemstone.OwnerId, OwnerName = gemstone.OwnerName }; inventory.Items[equipUid].Stats.GemSockets[slot].Gemstone = gemstone; session.Send(ItemSocketSystemPacket.UpgradeGem(equipUid, slot, newGem)); }
public static void GiveItemFromOpenBox(GameSession session, Item item) { OpenItemBox box = item.Function.OpenItemBox; ItemDropMetadata metadata = ItemDropMetadataStorage.GetItemDropMetadata(box.BoxId); if (metadata == null) { session.Send(NoticePacket.Notice("No items found", NoticeType.Chat)); return; } if (box.AmountRequired > item.Amount) { return; } Inventory inventory = session.Player.Inventory; if (box.RequiredItemId > 0) { Item requiredItem = inventory.Items[box.RequiredItemId]; if (requiredItem == null) { return; } inventory.ConsumeItem(session, requiredItem.Uid, 1); } inventory.ConsumeItem(session, item.Uid, box.AmountRequired); Random rng = RandomProvider.Get(); // Receive one item from each drop group if (box.ReceiveOneItem) { foreach (DropGroup group in metadata.DropGroups) { //randomize the contents List <DropGroupContent> contentList = group.Contents.OrderBy(x => rng.Next()).ToList(); foreach (DropGroupContent dropContent in contentList) { List <Item> items = GetItemsFromDropGroup(dropContent, session.Player.Gender, session.Player.Job); foreach (Item newItem in items) { inventory.AddItem(session, newItem, true); } } } return; } // receive all items from each drop group foreach (DropGroup group in metadata.DropGroups) { foreach (DropGroupContent dropContent in group.Contents) { List <Item> items = GetItemsFromDropGroup(dropContent, session.Player.Gender, session.Player.Job); foreach (Item newItem in items) { inventory.AddItem(session, newItem, true); } } } }
public void OnPointerDown(PointerEventData data) { if (this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() == null) { bool gearable = false; Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } if (data.button == PointerEventData.InputButton.Left && DoubleClick() && item.itemType == ItemType.Consumable) // if we doubleClick with the mouse's left button { //item from craft system to inventory if (transform.parent.GetComponent <CraftResultSlot>() != null) { bool check = inv.GetComponent <Inventory>().checkIfItemAllreadyExist(item.itemID, item.itemValue); if (!check) { for (int j = 0; j < inv.transform.GetChild(1).transform.childCount; j++) { if (inv.transform.GetChild(1).transform.GetChild(j).childCount != 0) { //if the item we're crafting has a slot filled in the main inventory and there are some places if (item.itemID.Equals(inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemID) && inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue != inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack) { //filling the remaining places before adding the rest through the normal add if (inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue + item.itemValue > inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack) { item.itemValue -= (inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack - inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue); inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue = inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack; } } } } //normal add numberOfItems = item.itemValue / item.maxStack; for (int i = 0; i < numberOfItems; i++) { inv.GetComponent <Inventory>().addItemToInventory(item.itemID, item.maxStack); inv.GetComponent <Inventory>().stackableSettings(); } if (item.itemValue % item.maxStack != 0) { inv.GetComponent <Inventory>().addItemToInventory(item.itemID, item.itemValue % item.maxStack); inv.GetComponent <Inventory>().stackableSettings(); } } CraftSystem cS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.GetComponent <CraftSystem>(); cS.deleteItems(item); CraftResultSlot result = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.transform.GetChild(3).GetComponent <CraftResultSlot>(); tooltip.deactivateTooltip(); gearable = true; inv.GetComponent <Inventory>().updateItemList(); } else { bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; if (eS.transform.GetChild(1).GetChild(i).parent.parent.GetComponent <EquipmentSystem>() != null && this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() != null) { } else { inventory.EquiptItem(item); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } } } }