/// Opens/Closes the market window void Market() { if (Input.GetKeyDown(KeyCode.M)) { if (marketPanel.activeSelf) { marketPanel.SetActive(false); } else { marketPanel.SetActive(true); if (!isAdded) { market.AddClothes(marketGrid, container, elements); isAdded = true; } } } bool isHave = false; // clicked = 1, didn`t click = 0, purchasing if (PlayerPrefs.GetInt("Clicked") == 1) { if (inventoryItems.Count < elements.Count) { foreach (Element element in elements) { if (element.Tag.ToString() == PlayerPrefs.GetString("ClickedTag")) { foreach (Element item in inventoryItems) { if (item.Tag.ToString() == PlayerPrefs.GetString("ClickedTag")) { isHave = true; break; } } if (!isHave) { if (gold.ValueGold > element.Price) { inventoryItems.Add(element); gold.ValueGold -= element.Price; PlayerPrefs.SetInt("GoldValue", gold.ValueGold); valueGoldTxt.text = PlayerPrefs.GetInt("GoldValue").ToString(); isHave = false; break; } } } } PlayerPrefs.SetInt("Clicked", 0); } } }