public void OnTap() { string _description = description; if (isVisible && (Score.totalAmountOfCoins >= amountOfDiamonsNeeded || isUnlocked)) { if (!isUnlocked) { PlayerPrefs.SetInt("unlockedCosmetics_" + name, 1); diamondImage.SetActive(false); amountOfDiamondsNeededText.text = ""; Score.totalAmountOfCoins -= amountOfDiamonsNeeded; PlayerPrefs.SetInt("amountOfDiamonds", Score.totalAmountOfCoins); Cosmetic_Previewer.singleton.amountOfCoins.text = Score.totalAmountOfCoins.ToString(); //GameManager.score. isUnlocked = true; } PlayerPrefs.SetInt("currentCosmeticChildNr", transform.GetSiblingIndex()); PlayerPrefs.SetString("currentCosmeticDescription", _description); GameManager.currentPlayer.spriteRenderer.sprite = unlockedSprite; Player_Mirror playerMirror = GameManager.currentPlayer.GetComponent <Player_Mirror>(); if (playerMirror != null) { playerMirror.reflectionSprite.sprite = unlockedSprite; } print("unlocked"); } else if (!isUnlocked && Score.totalAmountOfCoins < amountOfDiamonsNeeded) { _description = "You don't have enough diamonds. You need " + (amountOfDiamonsNeeded - Score.totalAmountOfCoins).ToString() + " more."; } Cosmetic_Previewer.singleton.ChangePreview(currentImage.sprite, _description); }
public void UnlockCosmetic() { PlayerPrefs.SetInt("unlockedCosmetics_" + lockedCosmeticName, 1); Score.totalAmountOfCoins -= int.Parse(amountOfDiamondsText.text); PlayerPrefs.SetInt("amountOfDiamonds", Score.totalAmountOfCoins); //Cosmetic_Previewer.singleton.amountOfCoins.text = Score.totalAmountOfCoins.ToString(); PlayerPrefs.SetInt("currentCosmeticChildNr", siblingIndex); PlayerPrefs.SetString("currentCosmeticDescription", cosmeticDescription.text); GameManager.currentPlayer.spriteRenderer.sprite = cosmeticImage.sprite; Player_Mirror playerMirror = GameManager.currentPlayer.GetComponent <Player_Mirror>(); if (playerMirror != null) { playerMirror.reflectionSprite.sprite = cosmeticImage.sprite; } CloseWindow(); }