public void Buy() { shopLogic.DecreaseEconomy(Convert.ToInt32(price.text)); soldOut.SetActive(true); this.GetComponent <Button>().interactable = false; foreach (GameObject pet in shopLogic.actualSellingPetsGameObject) { if (this.GetComponentInParent <SellingPetMarker>().gameObject == pet) { asociatedMesh = shopLogic.actualSellingPets[shopLogic.actualSellingPetsGameObject.IndexOf(pet)].prefab; roomsLogic.SetNewMesh(asociatedMesh); roomsLogic.SetNewRarity(shopLogic.actualSellingPets[shopLogic.actualSellingPetsGameObject.IndexOf(pet)].rarity); shopLogic.InstanciatePetName(); shopLogic.actualHoldingPets.Add(shopLogic.actualSellingPets[shopLogic.actualSellingPetsGameObject.IndexOf(pet)]); shopLogic.actualSellingPets.RemoveAt(shopLogic.actualSellingPetsGameObject.IndexOf(pet)); shopLogic.actualSellingPetsGameObject.Remove(pet); break; } } shopLogic.actualSoldPets = roomsLogic.roomsGameobjects; shopLogic.ShowUIPiece(buttonShop); shopLogic.ShowUIPiece(economy_ui); shopLogic.ShowUIPiece(lockUnlock); shopLogic.CloseShop(shop); }