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); }
public void Sell() //2 DO HERE : BASE ECONOMY INCREASE ON DAY PASSED && IF PET IS DEAD SELL FOR 1$ { shopLogic.IncreaseEconomy(Convert.ToInt32(price.text)); sold.SetActive(true); this.GetComponent <Button>().interactable = false; GameObject aux = shopLogic.actualSoldPets[index].gameObject; Debug.Log("ListCount: " + shopLogic.actualSoldPets.Count); //update shops positions : for (int i = 0; i < roomsLogic.roomsGameobjects.Count; i++) { roomsLogic.roomsGameobjects[i].transform.position = roomsLogic.gridPositions[i]; } roomsLogic.i--; shopLogic.actualSoldPets.RemoveAt(index); shopLogic.actualHoldingPets.RemoveAt(index); Destroy(aux); shop.GetComponent <ShopButtons>().BuyButtonClick(); shopLogic.ShowUIPiece(buttonShop); shopLogic.ShowUIPiece(economy_ui); shopLogic.ShowUIPiece(lockUnlock); shopLogic.CloseShop(shop); shopLogic.ResetSellGameObjectList(); // }